<!-- /* Font Definitions */ @font-face {font-family:宋体; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-alt:SimSun; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} @font-face {font-family:"Cambria Math"; panose-1:2 4 5 3 5 4 6 3 2 4; mso-font-charset:0; mso-generic-font-family:roman; mso-font-pitch:variable; mso-font-signature:-1610611985 1107304683 0 0 159 0;} @font-face {font-family:"/@宋体"; panose-1:2 1 6 0 3 1 1 1 1 1; mso-font-charset:134; mso-generic-font-family:auto; mso-font-pitch:variable; mso-font-signature:3 135135232 16 0 262145 0;} /* Style Definitions */ p.MsoNormal, li.MsoNormal, div.MsoNormal {mso-style-unhide:no; mso-style-qformat:yes; mso-style-parent:""; margin:0cm; margin-bottom:.0001pt; text-align:justify; text-justify:inter-ideograph; mso-pagination:none; font-size:10.5pt; mso-bidi-font-size:12.0pt; font-family:"Times New Roman","serif"; mso-fareast-font-family:宋体; mso-font-kerning:1.0pt;} .MsoChpDefault {mso-style-type:export-only; mso-default-props:yes; font-size:10.0pt; mso-ansi-font-size:10.0pt; mso-bidi-font-size:10.0pt; mso-ascii-font-family:"Times New Roman"; mso-fareast-font-family:宋体; mso-hansi-font-family:"Times New Roman"; mso-font-kerning:0pt;} /* Page Definitions */ @page {mso-page-border-surround-header:no; mso-page-border-surround-footer:no;} @page Section1 {size:612.0pt 792.0pt; margin:72.0pt 90.0pt 72.0pt 90.0pt; mso-header-margin:36.0pt; mso-footer-margin:36.0pt; mso-paper-source:0;} div.Section1 {page:Section1;} -->
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");
else
printf("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;
else
return 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;
}