勤能补拙,Expter

成都游戏Coder,记录游戏开发过程的笔记和心得!

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

1.指针运算

注意 ,每个例子不只是一个题目,可能有多个,用//....................................来分开的
# include <iostream>
# include 
<stdio.h>
using namespace std;

enum string
{
    x1,x2,x3
=10,x4,x5,
}X;

int main()
{
    
//测试1
   
    cout << x1 << x5<<endl;
    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] <<endl;
    cout << sizeof(t)<<endl;
   


//....................................
    int a[5= {1,2,3,4,5};
    cout 
<< *( (int *)(&a+1)-2<<endl; 


                
int  i=0;
    
int  j=1;
    
long *= NULL;
    
char *= NULL;
    
if(j++ && i++)
        p
++,c++;
    
if(i++ || j++)
        p
++,c++;

    cout 
<< i <<" " << j << " " << *<< " " << (long *)c <<endl;


   
//....................................
    int i =1;
   
int c = (i++) + (i++) + (i++);

    cout 
<< c <<" "<< i<<endl;

    
return 0;
}

2.
# include <iostream>
# include 
<stdio.h>
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
<<tmp<<endl;
    cout 
<< sizeof(tmp) << " " <<strlen(tmp)<<" "<< tmp<<endl;

   
//....................................
    char arr[100]  = "hello world";
    
int  *= (int *)arr;
    v[
0= 0X61626364;
    v[
1= 0X41424344;
    v[
2= 0X31323334;
    v[
3= 0;
    cout
<<arr<<endl;
   
    //....................................
    foo(3);
    return 0;
}


posted on 2008-12-06 10:27 expter 阅读(1160) 评论(2)  编辑 收藏 引用 所属分类: 其他学习笔记面试笔记算法与数据结构

评论

# re: 09年我曾经遇到的笔试题目[未登录] 2008-12-09 15:27 region

这些题不难,只要对内存有点理解
最后一道是3G门户的笔试题.  回复  更多评论   

# re: 09年我曾经遇到的笔试题目 2009-09-24 11:38 hljleo

p1 = (unsigned char *)0x801000; //char是一字节指针
p2 = (unsigned long *)0x801000; //unsigned long是四字节
//5*4=20  回复  更多评论   


只有注册用户登录后才能发表评论。
网站导航: 博客园   IT新闻   BlogJava   知识库   博问   管理