华为笔试题- 软件华为的最近的 C 语言笔试题 2008-03-06 21:37 一、判断题(对的写 T ,错的写 F 并说明原因,每小题 4 分,共 20 分) 1 、有数组定义 int a[2][2]={{1},{2,3}}; 则 a[0][1] 的值为 0。() 2、 int (*ptr) (), 则 ptr 是一维数组的名字。() 3 、指针在任何情况下都可进行>, <, >=, <=, == 运算。() 4、 switch(c) 语句中 c 可以是 int, long, char, float, unsigned int 类型。() 5、#define print(x) printf( " the no, " #x" ,is ") 二、填空题(共 30 分) 1 、在 windows 下,写出运行结果,每空 2 分,共 10 分。 char str[ ]=" Hello "; char *p=str; int n=10; sizeof(str)=( ) sizeof(p)=( ) sizeof(n)=( ) void func(char str[100]) {} sizeof(str)=( )2、 void setmemory(char **p, int num) { *p=(char *) malloc(num);} void test(void) { char *str=NULL; getmemory(&str,100); strcpy(str, " hello " ); printf(str); } 运行 test 函数有什么结果? () 10分 3 、设 int arr[]={6,7,8,9,10}; int *ptr=arr; *(ptr++)+=123; printf( " %d,%d " ,*ptr,*(++ptr)); () 10分二、编程题(第一小题 20 ,第二小题 30 分) 1、不使用库函数,编写函数 int strcmp(char *source, char *dest) 相等返回 0 ,不等返回-1; 2、写一函数 int fun(char *p) 判断一字符串是否为回文,是返回1 ,不是返回 0 ,出错返回-1 *********************************************************** 找错 Void test1() { char string[10]; char* str1= ” 0123456789 ”; strcpy(string, str1); } Void test2() { char string[10], str1[10]; for(I=0; I<10;I++) { str1[i] =’a’;} strcpy(string, str1); } Void test3(char* str1) { char string[10]; if(strlen(str1)<=10) { strcpy(string, str1); }} 2. 找错#define MAX_SRM 256 DSN get_SRM_no() { static int SRM_no; int I; for(I=0;I{ SRM_no %= MAX_SRM; if(==ID
华为笔试题-软件 来自淘豆网www.taodocs.com转载请标明出处.