09年我曾经遇到的笔试题目

来源:百度文库 编辑:神马文学网 时间:2024/04/28 15:44:28
http://www.cppblog.com/expter/archive/2008/12/06/68711.html
1.指针运算
注意 ,每个例子不只是一个题目,可能有多个,用//....................................来分开的
# include 
# include 
using namespace std;
enum string
{
x1,x2,x3=10,x4,x5,
}X;
int main()
{
//测试1
cout << x1 << x5<unsigned char *p1;
unsigned long *p2;
p1 = (unsigned char *)0x801000;
p2 = (unsigned long *)0x801000;
printf("%p\n",p1+5);
printf("%p\n",p2+5);
char * t [] = { "abccc","daa","caa"};
char **bb = t;
cout << t[1] <cout << sizeof(t)<//....................................
int a[5] = {1,2,3,4,5};
cout << *( (int *)(&a+1)-2) <int  i=0;
int  j=1;
long *p = NULL;
char *c = NULL;
if(j++ && i++)
p++,c++;
if(i++ || j++)
p++,c++;
cout << i <<" " << j << " " << *p << " " << (long *)c <//....................................
int i =1;
int c = (i++) + (i++) + (i++);
cout << c <<" "<< i<return 0;
}
2.
# include 
# include 
using namespace std;
void foo(int k)
{
char tmp[100];
//sprintf(tmp,"%d",k);
printf("%d\n",tmp);
foo(k-1);
}
int main()
{
int  i= 0;
int  x= 0;
int  y= 0;
printf("%d %d %d %d\n",x--,++y,i++,i++);
char tmp[20]="hello\0\t\\\\world";
cout<cout << sizeof(tmp) << " " <//....................................
char arr[100]  = "hello world";
int  *v = (int *)arr;
v[0] = 0X61626364;
v[1] = 0X41424344;
v[2] = 0X31323334;
v[3] = 0;
cout<//....................................
foo(3);
return 0;
}
# re: 09年我曾经遇到的笔试题目 2009-09-24 11:38
p1 = (unsigned char *)0x801000; //char是一字节指针
p2 = (unsigned long *)0x801000; //unsigned long是四字节
//5*4=20
(#)