1. 结构POINT定义如下: typedef struct tagPOINT { int x; int y; } POINT 用变量var给出下面的定义 例:一个POINT 变量 答案:POINT var; a. 一个指向POINT的指针; POINT *p; b. 一个指向指针的指针,它指向的指针是指向一个POINT; c. 一个有16个POINT的数组; d. 一个有16个指针的数组,每个指针指向一个POINT; e. 一个指向数组的指针,该数组有16个POINT 2. 实现函数IsEven,用于判断一个给定的整数是否为偶数 3. 写一个函数,实现对给定的字符串(字符串里面包括:英文字母,数字,符号)的处理。经过处理后的字符串其内容按字母,数字,符号的顺序存放。函数声明如下:void ParseString(char* pstr); 要求: a. 不能改函数声明; b. 不改变字母数字等在字符串中原有的出现顺序; c. 直接使用pstr所值指缓冲区,不允许另开缓冲区。 例如:给定的字符串为:A,2.d?3!e4r87we79... 输出结果为:Aderwe2348779,.?!... 4. 写一个函数,对给定整数的二进制表示进行描述如:给定整数131,其二进制表示为10000011,要求函数输出以下结果: 1: 2 0: 5 1: 1 表示从最低位开始,包含2个1,5个0,1个1。 参考上一题,确定本函数的名字,入口出口及返回值,并实现本函数 5. 定义一个student类,成员变量包含学生姓名、出生年月日。要求重载“>”运算符,实现以出生年月日为依据比较两个学生年龄大小的功能。 6. 有如下3个API: HANDLE FindFirst(char* lpFileName);//用于查找给定目录下是否有指定文件。若无则返回0,若有则返回一个句柄。例如:FindFirst("D:\\data\\*.txt") BOOL FindNext(HANDLE hFindFile); //继续查找该目录下是否有其他匹配文件。 BOOL FindClose(HANDLE hFindFile);//用于结束查找。 利用上述API实现函数NumOfPicFiles,找出给定目录下有多少个JPG及BMP文件(不考虑子目录)。 int NumOfPicFiles(char*lpszfolder); Lpszfolder表示指定目录。 返回值表示找到的文件个数。 1. a. 答:... POINT *p; b. 答:... typedef POINT *P; P *p2; c. 答:... POINT s[16]; d. 答:...POINT *p4; p4=(POINT *)malloc(16*sizeof(POINT)); e. 答:... 2. #include <stdio.h>bool IsEven(int a){if(a%2==0) return true;return false;}int main(){int a;scanf("%d",&a);if(IsEven(a))printf("Yes\n");elseprintf("No\n");} 3. #include <iostream.h>#include <ctype.h>void ParseString(char* pstr){char c;int a,i;a=0,i=0;//char pstr[50];//cin>>pstr;while(pstr[i]!='\0'){if(isalpha(pstr[i])){c=pstr[i];pstr[i]=pstr[a];pstr[a]=c;a++;//cout<<c<<endl;}i++;}i--;a=i;while(i!=0){if(!isalnum(pstr[i])){c=pstr[i];pstr[i]=pstr[a];pstr[a]=c;a--;}i--;}//cout<<pstr<<endl;}int main(){char s[100];cin>>s;ParseString(s);cout<<s<<endl;} 4. #include <stdio.h>void ParseInt(int pint){int sum;int b=pint%2;pint=pint/2;sum=1;int a;while(pint!=0){a=pint%2;if(a==b)sum++;else{printf("%d:%d\n",b,sum);sum=1;}b=a;pint=pint/2;}printf("1:1\n");}int main(){int a;scanf("%d",&a);ParseInt(a);} 5. #include <iostream.h>class student{char name[12];int year;int month;int day;};class operator>(student &s1,student &s2){if(s1.year*365+s1.month*30+s1.day>s2.year*365+s2.month*30+s2.day)return true;elsereturn false;}int main(){student s1,s2;cin>>s1.name>>s1.year>>s1.month>>s1.day;cin>>s2.name>>s2.year>>s2.month>>s2.day;if(s1>s2) cout<<"s1>s2"<<endl;} 6 没时间,没做~

评论