1、 一、选择题(共30分,每小题2分) 题目1 题干 假定有“struct BOOK{char title[40]; float price;}; struct BOOK book;”,则不正确的语句为( )。 选择一项: a. struct BOOK *x=malloc(book); b. struct BOOK x={"C++ Programming",27.0}; c. struct BOOK *x=malloc(sizeof(struct BOOK)); d. struct BOOK *x=&book; 题目2 题干 假定有“struct BOOK{char
2、 title[40]; float price;} book;”,则正确的语句为( )。 选择一项: a. struct BOOK x= &book; b. struct BOOK *x=&book; c. struct BOOK x=calloc(BOOK); d. struct BOOK *x=BOOK; 题目3 题干 在结构类型的定义中,不同数据成员的定义项之间采用的分隔符是( )。 选择一项: a. 句点 b. 冒号 c. 分号 d. 逗号 题目4 题干 假定一个结构类型的定义为 “struct A{int a,b; double c;};”
3、则该类型的长度为( )。 选择一项: a. 8 b. 10 c. 12 d. 16 题目5 题干 假定一个结构类型的定义为 “struct D{int a; D* next;};”,则该类型的长度为( )。 选择一项: a. 4 b. 8 c. 12 d. 16 题目6 题干 假定要访问一个结构指针变量x中的数据成员a,则表示方法为( )。 选择一项: a. x.a b. x->a c. x(a) d. x{a} 题目7 题干 与结构成员访问表达式x.name等价的表达式为( )。 选择一项: a. x->n
4、ame b. &x->name c. (&x)->name d. (*x)->name 题目8 题干 假定一个链表中结点的结构类型为“struct AA{int data, struct AA *next;};”,则next数据成员的类型为( )。 选择一项: a. struct AA b. struct AA* c. AA d. int 题目9 题干 假定一个链表的表头指针为f,结点中包含有data和next域,则向该链表的表头插入一个地址为p的结点时,应执行的操作为( )。 选择一项: a. p->next=f b. p->next=f
5、和f=p c. f=p->next d. f->next=p和f=p 题目10 题干 标准输入设备键盘的文件流标识符是( )。 选择一项: a. stdin b. stdout c. stderr d. stdio 题目11 题干 表示文件结束符的符号常量为( )。 选择一项: a. eof b. Eof c. EOF d. feof 题目12 题干 C语言中打开一个数据文件的系统函数为( )。 选择一项: a. fgetc() b. fputc() c. fclose() d. fopen() 题目13 题干
6、 从一个数据文件中读入以换行符结束的一行字符串的系统函数为( )。 选择一项: a. gets() b. fgets() c. getc() d. fgetc() 题目14 题干 向一个二进制文件中写入信息的函数fwrite()带有的参数个数为( )。 选择一项: a. 1 b. 2 c. 3 d. 4 题目15 题干 在C语言中,为只写操作打开一个文本文件的方式为( )。 选择一项: a. "a" b. "r+" c. "r" d. "w" 信息文本 二、判断题(共40分,每小题2分。叙述正确则回答“是”,否则回答“否”
7、 题目16 题干 在结构类型的定义中,其中的数据成员可以是本身类型的直接对象。 选择一项: 对 错 题目17 题干 在结构类型的定义中,允许出现结构类型不完整的超前定义。 选择一项: 对 错 题目18 题干 定义结构类型的变量时,不能够同时进行初始化。 选择一项: 对 错 题目19 题干 使用一个结构类型时,必须一起使用关键字struct和类型标识符。 选择一项: 对 错 题目20 题干 假定一个结构类型的定义为 “struct A{int a,b; A* c;};”,则该类型的长度为12。 选择一项: 对 错 题目21
8、 题干 假定一个结构类型的定义为 “struct B{int a[5]; char* b;};”,则该类型的长度为20。 选择一项: 对 错 题目22 题干 执行calloc(n,8)函数调用时,将动态分配得到8*n个字节的存储空间。 选择一项: 对 错 题目23 题干 执行malloc(sizeof(struct BB))函数调用时,得到的动态存储空间能够保存具有struct BB结构类型的一个对象。 选择一项: 对 错 题目24 题干 假定要访问一个结构对象x中的由a指针成员所指向的对象,则表示方法为x.a。 选择一项: 对 错 题目25 题
9、干 假定要访问一个结构指针p所指对象中的b指针成员所指的对象,则表示方法为p->b。 选择一项: 对 错 题目26 题干 与结构成员访问表达式(*fp).score等价的表达式是fp->score。 选择一项: 对 错 题目27 题干 在C语言中,对二进制文件的所有不同打开方式共有6种。 选择一项: 对 错 题目28 题干 C语言中的标准输入和输出设备文件都属于字符文件。 选择一项: 对 错 题目29 题干 在一个磁盘数据文件的文件名中,文件主名和扩展名都是必须的,不可省略。 选择一项: 对 错 题目30 题干 在数据文件打
10、开方式字符串中,字符r、w和a具有确定的含义,分别代表读、写和追加方式。 选择一项: 对 错 题目31 题干 一个磁盘数据文件的文件名由文件主名和扩展名所组成,其中间用圆点分开。 选择一项: 对 错 题目32 题干 C语言系统中提供一个用来描述文件属性的类型标识符为FILE。 选择一项: 对 错 题目33 题干 每次只能向文本文件中写入一个字符,不能一次写入一个字符串。 选择一项: 对 错 题目34 题干 对二进制文件进行读和写操作将使用相同的系统函数。 选择一项: 对 错 题目35 题干 在C语言中,系统函数fseek()用
11、来移动数据文件中的文件位置指针。
选择一项:
对
错
信息文本
三、写出下列每个程序运行后的输出结果(共15分,每小题5分)
题目36
题干
#include
12、300};
struct Worker y, *p;
y=x; p=&x;
printf("%s %d %6.2f\n",x.name,y.age,p->pay);
}
wanghua 52 4300
题目37
题干
#include
13、龄 float pay; //工资 }; void main() { struct Worker x; char *t="liouting"; int d=38; float f=3493; strcpy(x.name,t); x.age=d; x.pay=f; printf("%s %d %6.0f\n",x.name,x.age,x.pay); } li
14、outing 39 2493
题目38
题干
#include 15、},{"def",58,4638},
{"ghi",49,4260},{"jkl",36,3750}};
struct Worker x=a[0];
int i;
for(i=1; i<4; i++)
if(Less(x,a[i])) x=a[i];
printf("%s %d %6.0f\n",x.name,x.age,x.pay);
}
def 58 4638
信息文本
四 16、写出下列每个函数的功能(共15分,每小题5分)
题目39
题干
void QA(struct Worker a[], int n) {
int i;
for(i=1; i 17、orker类型的记录到一维数组a中。
题目40
题干
int Count(struct IntNode *f)
{ //f为指向一个单链表的表头指针
int c=0;
while(f) {
c++;
f=f->next;
}
return c;
}
假定struct IntNode的类型定义为:
struct IntNode {i 18、nt data; IntNode* next;};
统计出以表头指针为f的链表中结点的个数。
题目41
题干
void xw1(char* fname) {
FILE* fout=fopen(fname,"w");
char a[20];
printf("每个字符串长度小于20,字符串end作为结束标志\n");
while(1) {
scanf("%s",a);
if(strcmp(a,"end")==0) break;
fputs(a,fout);
fputc('\n',fout);
}
fclose(fout);
}
把从键盘上输入的若干个字符串保存到由fname参数所指定的文本文件中。
(注:专业文档是经验性极强的领域,无法思考和涵盖全面,素材和资料部分来自网络,供参考。可复制、编制,期待你的好评与关注)






