《计算机编程语言—C语言》第58卷:结构体、共用体及链表 - 知识点训练卷 湖南省计算机应用考纲百套卷

2025-06-16
| 2份
| 21页
| 172人阅读
| 1人下载

内容正文:

编写说明:《计算机应用考纲百套卷》依据湖南省《计算机应用类专业知识考试标准》编写,本套试卷共100份,分为三个部分,第一部分是知识点训练卷,共62份,第二部分是常考题训练卷,共18份,第三个部分是专业综合训练卷,参考历年计算机应用类专业真题试卷,编写了20份。 本试卷是《计算机应用考纲百套卷》的第58卷,知识点:①结构体的定义及初始化;②结构体数组;③结构体与指针;④共用体的定义及初始化;⑤动态分配存储空间;⑥链表(建立链表、删除链表中的结点、向链表插入结点、链表的合并);⑦枚举类型及类型定义符; 湖南省《计算机应用考纲百套卷》 《计算机编程语言-C语言》 第58卷: 结构体、共用体及链表 知识点训练卷 时间:45分钟 总分:100分 班级___________ 姓名__________ 学号__________ 成绩________ 一、选择题(共20小题,每小题2分,共40分) 1.在VC++ 2010中,当定义一个结构体变量时,系统为它分配的内存空间是( ) A.结构体中第一个成员所需的内存容量 B.结构体中一个成员所需的内存容量 C.成员中站内存量最大者所需的容量乘以所有成员的个数 D.结构体中各个成员所需内存容量之和 2.若有下列定义和赋值,则使用( )不可以输出n中data的值。 struct snode{unsigned ID;int data;}n,*p;p=&n; A.p.data B.n.data C.p->data D.(*p).data 3.下列叙述中错误的是( ) A.用typedef定义新的类型名后,原有类型名仍然有效 B.可以用typedef将已存在的类型用一个新的名字来代表 C.可以通过typedef增加新的类型 D.用typedef可以为各种类型起别名,但不能为变量起别名 4.以下结构体类型说明和变量定义中,正确的一项是( ) A.typedef struct{int n;char c;}REC;REC t1,t2; B.struct REC;{int n;char c;};REC t1,t2; C.typedef struct REC:{int n=0;char c=‘A’;}t1,t2;REC t1,t2; D.struct {int n;char c;}REC; 5.设有语句:typedef struct S{int g;char h;}T;,则下列叙述中正确的一项是( ) A.可以使用S定义结构体变量 B.可以使用T定义结构体变量 C.S是struct类型的变量 D.T是struct S类型的变量 6.执行以下程序段的输出结果是( ) main() {struct point{int x;int y;}; struct point p={10,20}; struct point *ptr=&p; printf("%d ",ptr->x);getch();} A.10 B.20 C.30 D.不确定值 7.设有以下定义和语句,能给w中year成员赋值1998的语句是( ) struct workers {int num; char name[10]; char c; struct{int day;int month;int year;}s;}; struct workers w,*pw; pw=&w; A.*pw.year=1998; B.w.year=1998; C.pw->year=1998; D.w.s.year=1998; 8.设有定义:struct{int n;char c;}a[2],*p=a;,则下列选项中错误引用结构体成员n的是( ) A.(*a)->11 B.a[0].n C.p->n D.(*p).n 9. 有如下结构体阐明、变量定义和赋值语句, 则如下scanf函数调用语句中错误引用结构体变量组员的是( ) struct STD {char name[10];int age;char sex;}s[5],*ps;ps=&s[0]; A.scanf(“%s”,s[0].name); B.scanf(“%d”,&s[0].age); C.scanf(“%c”,&(ps->sex)); D.scanf(“%d”,ps->age); 10. 若有如下定义和语句, 则如下语句正确的是( ) union data { int i; char c; float f;}x;int y; A.x=10.5; B.x.c=101; C.y=x; D.printf(“%d ”,x); 11.C语言结构体类型变量在程序执行期间( ) A.所有成员一直驻留在内存中 B.只有一个成员驻留在内存中 C.部分成员驻留在内存中 D.没有成员驻留在内存中 12.执行以下程序段的输出结果是( ) main() {struct cmplx{int x;int y;}cnum[2]={1,3,2,7}; printf("%d ",cnum[0].y/cnum[0].x*cnum[1].x);getch();} A.0 B.1 C.3 D.6 13.下列叙述中,不正确的一项是( ) A.枚举变量只能取对应枚举类型的枚举元素表中的元素 B.可以在定义枚举类型时对枚举元素进行初始化 C.枚举元素表中的元素有先后次序,可以进行比较 D.枚举元素的值可以是整数或字符串 14.设有下图a所示的存储结构,且变量定义为:struct node{int data;struct node *next;}*p,*q,*r;,若要实现下图b所示的存储结构,可以选用的赋值语句是( ) A.p=r; B.p=q->next; C.p->next=q; D.p->next=q->next; 15.下列程序段的运行结果是( ) main() {struct stu{char name[10];int age,sex;}; printf("%d",sizeof(struct stu));getch();} A.10 B.18 C.14 D.20 16.设有如下结点定义及链表情况,删除其中学号为101的语句是( ) struct node{int num;struct node *next;}*head,*p; A.p=head->next;p->next=head->next;free(p); B.p=head->next;free(head);head=p; C.p=head->next;head->next=p->next;free(p); D.p=head->next;free(p->next);p->next=NULL; 17.某结构体说明和变量定义如下所示,则下列选项中,能够将结点b链接到结点a之后的语句是( ) struct node{int data;struct node *next;}a,b,*pa=&a,*pb=&b; A.a.next=b; B.pa->next=(*pb); C.a->next=&b; D.(*pa).next=pb; 18. 设有定义:struct {char mark[12];int num1;double num2;} t1,t2;,若变量均已正确赋初值,则如下语句中错误的是( ) A.t1=t2; B.t2.num1=t1.num1; C.t2.mark=t1.mark; D.t2.num2=t1.num2; 19.执行以下程序段的输出结果是( ) struct ord{int x,y;}dt[4]={1,2,3,4}; main() {struct ord *p=dt; printf("%d,",++(p->x)); printf("%d ",++(p->y));getch();} A.1,2 B.4,1 C.3,4 D.2,3 20.执行以下程序段的输出结果是( ) struct S{int a,b;}data[2]={10,100,20,200}; main() {struct S p=data[1]; printf("%d ",++(p.a));getch();} A.10 B.11 C.20 D.21 二、程序运行结果题(本题共6题,每题4分,共24分) 21. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> main() {char *p; int i; p=(char *)malloc(sizeof(char)*20); strcpy(p,"welcome"); for(i=6;i>=0;i--) putchar(*(p+i)); printf(" "); free(p); getch();} 22. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> #include<string.h> typedef struct {char name[9]; char sex; int score[2];} STU; STU f(STU a) {STU b={"Zhao",'m',85,90}; int i; strcpy(a.name, b.name); a.sex=b.sex; for (i=0; i<2; i++) a.score[i]=b.score[i]; return a;} main( ) {STU c={"Qian",'f',95,92}, d; d=f(c); printf("%s,%c,%d,%d,",d.name,d.sex,d.score[0],d.score[1]); printf("%s,%c,%d,%d ",c.name,c.sex,c.score[0],c.score[1]); getch();} 23. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> main(){ struct node {int n; struct node *next;} *p; struct node x[3]={{2,x+1}, {4,x+2}, {6, NULL}}; p=x; printf("%d,", p->n ); printf("%d ",p->next->n ); getch();} 24. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> struct stu {int mun; char name[10]; int age;}; void fun(struct stu *p) { printf("%s ",p->name);} main() { struct stu x[3]={{01,"zhang",20},{02,"wang",19},{03,"zhao",18}}; fun(x+2); getch();} 25. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> main() {char *p, *q, *r; p=q=r=(char *)malloc(sizeof(char)*20); strcpy(p,"attaboy,welcome!"); printf("%c%c%c ",p[11], q[3], r[4]); free(p); getch();} 26. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> struct node {int data;int next;}; main() {int i=0; struct node list[3]; list[0].data=1; list[0].next=1; list[1].data=2; list[1].next=2; list[2].data=3; list[2].next=-1; while(i!=-1) {printf("%d ",list[i].data); i=list[i].next;}getch();} 三、程序填空题(本题共2题,每空4分,共24分) 27. 已知 head指向一个带头结点的单向链表,链表中每个结点包含数据域(data) 和指针域(next),数据域为整型。以下函数求出链表中所有链结点数据域的 和值,作为函数值返回。请填空。 struct link { int data; struct link *next;}; main( ) {struct link *head; …… sum(head); …… } int sum(【1】) {struct link *p; int s=0; p=head->next; while(p) {s+=【2】; p=【3】;} return (s);} 28. 已知 head 指向一个带头结点的单向链表,链表中每个结点包含数据域(data)和指针域(next),数据域为整型。以下过程求出链表所有链结点中,数据域值最大的结点的位置,由指针变量s传回调用程序。请填空。 struct link {int data; struct link *next;}; main( ) { struct link * head,*q; …… fmax(head,&q); printf("max=%d ",q->data ); …… } void fmax( struct link * head,【1】) { struct link *p; p=(*head).next; *s=p; while(p!=NULL) { p=【2】; if(【3】) *s=p;} } 四、程序改错题(本题共1题,每空4分,共12分) 29.下列程序的功能是:实现将两个带头结点的有序链表合并成一个有序链表的函数(由小到大排序)。程序中共有三处错误,请改正。 L1 struct link L2 {int data; L3 struct link *next;}; L4 struct link *hbsort(link *a,link *b,link *c) L5 {struct link *pa,*pb,*pc; L6 pa=a->next; L7 pb=b->next; L8 pc=a;c=pc; L9 while(pa->netx!=NULL&&pb->netx!=NULL) L10 if(pa->data<pb->data) L11 {pc->next=pa; L12 pc=pa; L13 pa=pa->next;} L14 else L15 {pc->next=pb; L16 pc=pb; L17 pb=pb->next;} L18 if(pa->netx!=NULL) L19 pc->next=pa; L20 else pc->next=pb; L21 return c;} 原创精品资源学科网独家享有版权,侵权必究! 学科网(北京)股份有限公司 学科网(北京)股份有限公司 $$ 编写说明:《计算机应用考纲百套卷》依据湖南省《计算机应用类专业知识考试标准》编写,本套试卷共100份,分为三个部分,第一部分是知识点训练卷,共62份,第二部分是常考题训练卷,共18份,第三个部分是专业综合训练卷,参考历年计算机应用类专业真题试卷,编写了20份。 本试卷是《计算机应用考纲百套卷》的第58卷,知识点:①结构体的定义及初始化;②结构体数组;③结构体与指针;④共用体的定义及初始化;⑤动态分配存储空间;⑥链表(建立链表、删除链表中的结点、向链表插入结点、链表的合并);⑦枚举类型及类型定义符; 湖南省《计算机应用考纲百套卷》 《计算机编程语言-C语言》 第58卷: 结构体、共用体及链表 知识点训练卷 时间:45分钟 总分:100分 班级___________ 姓名__________ 学号__________ 成绩________ 一、选择题(共20小题,每小题2分,共40分) 1.在VC++ 2010中,当定义一个结构体变量时,系统为它分配的内存空间是( ) A.结构体中第一个成员所需的内存容量 B.结构体中一个成员所需的内存容量 C.成员中站内存量最大者所需的容量乘以所有成员的个数 D.结构体中各个成员所需内存容量之和 【答案】C 2.若有下列定义和赋值,则使用( )不可以输出n中data的值。 struct snode{unsigned ID;int data;}n,*p;p=&n; A.p.data B.n.data C.p->data D.(*p).data 【答案】A 3.下列叙述中错误的是( ) A.用typedef定义新的类型名后,原有类型名仍然有效 B.可以用typedef将已存在的类型用一个新的名字来代表 C.可以通过typedef增加新的类型 D.用typedef可以为各种类型起别名,但不能为变量起别名 【答案】C 4.以下结构体类型说明和变量定义中,正确的一项是( ) A.typedef struct{int n;char c;}REC;REC t1,t2; B.struct REC;{int n;char c;};REC t1,t2; C.typedef struct REC:{int n=0;char c=‘A’;}t1,t2;REC t1,t2; D.struct {int n;char c;}REC; 【答案】A 5.设有语句:typedef struct S{int g;char h;}T;,则下列叙述中正确的一项是( ) A.可以使用S定义结构体变量 B.可以使用T定义结构体变量 C.S是struct类型的变量 D.T是struct S类型的变量 【答案】B 6.执行以下程序段的输出结果是( ) main() {struct point{int x;int y;}; struct point p={10,20}; struct point *ptr=&p; printf("%d ",ptr->x);getch();} A.10 B.20 C.30 D.不确定值 【答案】A 7.设有以下定义和语句,能给w中year成员赋值1998的语句是( ) struct workers {int num; char name[10]; char c; struct{int day;int month;int year;}s;}; struct workers w,*pw; pw=&w; A.*pw.year=1998; B.w.year=1998; C.pw->year=1998; D.w.s.year=1998; 【答案】D 8.设有定义:struct{int n;char c;}a[2],*p=a;,则下列选项中错误引用结构体成员n的是( ) A.(*a)->11 B.a[0].n C.p->n D.(*p).n 【答案】A 9. 有如下结构体阐明、变量定义和赋值语句, 则如下scanf函数调用语句中错误引用结构体变量组员的是( ) struct STD {char name[10];int age;char sex;}s[5],*ps;ps=&s[0]; A.scanf(“%s”,s[0].name); B.scanf(“%d”,&s[0].age); C.scanf(“%c”,&(ps->sex)); D.scanf(“%d”,ps->age); 【答案】D 10. 若有如下定义和语句, 则如下语句正确的是( ) union data { int i; char c; float f;}x;int y; A.x=10.5; B.x.c=101; C.y=x; D.printf(“%d ”,x); 【答案】B 11.C语言结构体类型变量在程序执行期间( ) A.所有成员一直驻留在内存中 B.只有一个成员驻留在内存中 C.部分成员驻留在内存中 D.没有成员驻留在内存中 【答案】A 12.执行以下程序段的输出结果是( ) main() {struct cmplx{int x;int y;}cnum[2]={1,3,2,7}; printf("%d ",cnum[0].y/cnum[0].x*cnum[1].x);getch();} A.0 B.1 C.3 D.6 【答案】D 13.下列叙述中,不正确的一项是( ) A.枚举变量只能取对应枚举类型的枚举元素表中的元素 B.可以在定义枚举类型时对枚举元素进行初始化 C.枚举元素表中的元素有先后次序,可以进行比较 D.枚举元素的值可以是整数或字符串 【答案】D 14.设有下图a所示的存储结构,且变量定义为:struct node{int data;struct node *next;}*p,*q,*r;,若要实现下图b所示的存储结构,可以选用的赋值语句是( ) A.p=r; B.p=q->next; C.p->next=q; D.p->next=q->next; 【答案】D 15.下列程序段的运行结果是( ) main() {struct stu{char name[10];int age,sex;}; printf("%d",sizeof(struct stu));getch();} A.10 B.18 C.14 D.20 【答案】D。该题涉及到在VC中,内存字节对齐的问题。 16.设有如下结点定义及链表情况,删除其中学号为101的语句是( ) struct node{int num;struct node *next;}*head,*p; A.p=head->next;p->next=head->next;free(p); B.p=head->next;free(head);head=p; C.p=head->next;head->next=p->next;free(p); D.p=head->next;free(p->next);p->next=NULL; 【答案】B 17.某结构体说明和变量定义如下所示,则下列选项中,能够将结点b链接到结点a之后的语句是( ) struct node{int data;struct node *next;}a,b,*pa=&a,*pb=&b; A.a.next=b; B.pa->next=(*pb); C.a->next=&b; D.(*pa).next=pb; 【答案】D 18. 设有定义:struct {char mark[12];int num1;double num2;} t1,t2;,若变量均已正确赋初值,则如下语句中错误的是( ) A.t1=t2; B.t2.num1=t1.num1; C.t2.mark=t1.mark; D.t2.num2=t1.num2; 【答案】C 19.执行以下程序段的输出结果是( ) struct ord{int x,y;}dt[4]={1,2,3,4}; main() {struct ord *p=dt; printf("%d,",++(p->x)); printf("%d ",++(p->y));getch();} A.1,2 B.4,1 C.3,4 D.2,3 【答案】D 20.执行以下程序段的输出结果是( ) struct S{int a,b;}data[2]={10,100,20,200}; main() {struct S p=data[1]; printf("%d ",++(p.a));getch();} A.10 B.11 C.20 D.21 【答案】D 二、程序运行结果题(本题共6题,每题4分,共24分) 21. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> main() {char *p; int i; p=(char *)malloc(sizeof(char)*20); strcpy(p,"welcome"); for(i=6;i>=0;i--) putchar(*(p+i)); printf(" "); free(p); getch();} 【答案】emoclew 22. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> #include<string.h> typedef struct {char name[9]; char sex; int score[2];} STU; STU f(STU a) {STU b={"Zhao",'m',85,90}; int i; strcpy(a.name, b.name); a.sex=b.sex; for (i=0; i<2; i++) a.score[i]=b.score[i]; return a;} main( ) {STU c={"Qian",'f',95,92}, d; d=f(c); printf("%s,%c,%d,%d,",d.name,d.sex,d.score[0],d.score[1]); printf("%s,%c,%d,%d ",c.name,c.sex,c.score[0],c.score[1]); getch();} 【答案】Zhao,m,85,90,Qian,f,95,92 23. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> main(){ struct node {int n; struct node *next;} *p; struct node x[3]={{2,x+1}, {4,x+2}, {6, NULL}}; p=x; printf("%d,", p->n ); printf("%d ",p->next->n ); getch();} 【答案】2,4 24. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> struct stu {int mun; char name[10]; int age;}; void fun(struct stu *p) { printf("%s ",p->name);} main() { struct stu x[3]={{01,"zhang",20},{02,"wang",19},{03,"zhao",18}}; fun(x+2); getch();} 【答案】zhao 25. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> #include<string.h> #include<stdlib.h> main() {char *p, *q, *r; p=q=r=(char *)malloc(sizeof(char)*20); strcpy(p,"attaboy,welcome!"); printf("%c%c%c ",p[11], q[3], r[4]); free(p); getch();} 【答案】cab 26. 下列程序的运行结果是 #include<stdio.h> #include<conio.h> struct node {int data;int next;}; main() {int i=0; struct node list[3]; list[0].data=1; list[0].next=1; list[1].data=2; list[1].next=2; list[2].data=3; list[2].next=-1; while(i!=-1) {printf("%d ",list[i].data); i=list[i].next;}getch();} 【答案】1 2 3 三、程序填空题(本题共2题,每空4分,共24分) 27. 已知 head指向一个带头结点的单向链表,链表中每个结点包含数据域(data) 和指针域(next),数据域为整型。以下函数求出链表中所有链结点数据域的 和值,作为函数值返回。请填空。 struct link { int data; struct link *next;}; main( ) {struct link *head; …… sum(head); …… } int sum(【1】) {struct link *p; int s=0; p=head->next; while(p) {s+=【2】; p=【3】;} return (s);} 【答案】①struct link *head ②p->data ③p->next 28. 已知 head 指向一个带头结点的单向链表,链表中每个结点包含数据域(data)和指针域(next),数据域为整型。以下过程求出链表所有链结点中,数据域值最大的结点的位置,由指针变量s传回调用程序。请填空。 struct link {int data; struct link *next;}; main( ) { struct link * head,*q; …… fmax(head,&q); printf("max=%d ",q->data ); …… } void fmax( struct link * head,【1】) { struct link *p; p=(*head).next; *s=p; while(p!=NULL) { p=【2】; if(【3】) *s=p;} } 【答案】①struct link **s ②p->next ③(*p).data>(**s).data 四、程序改错题(本题共1题,每空4分,共12分) 29.下列程序的功能是:实现将两个带头结点的有序链表合并成一个有序链表的函数(由小到大排序)。程序中共有三处错误,请改正。 L1 struct link L2 {int data; L3 struct link *next;}; L4 struct link *hbsort(link *a,link *b,link *c) L5 {struct link *pa,*pb,*pc; L6 pa=a->next; L7 pb=b->next; L8 pc=a;c=pc; L9 while(pa->netx!=NULL&&pb->netx!=NULL) L10 if(pa->data<pb->data) L11 {pc->next=pa; L12 pc=pa; L13 pa=pa->next;} L14 else L15 {pc->next=pb; L16 pc=pb; L17 pb=pb->next;} L18 if(pa->netx!=NULL) L19 pc->next=pa; L20 else pc->next=pb; L21 return c;} 【答案】 ①L4 struct link *hbsort(struct link *a,struct link *b,struct link *c) ②L9 while(pa!=NULL&&pb!=NULL) ③L18 if(pa!=NULL) 原创精品资源学科网独家享有版权,侵权必究! 学科网(北京)股份有限公司 学科网(北京)股份有限公司 $$

资源预览图

《计算机编程语言—C语言》第58卷:结构体、共用体及链表 - 知识点训练卷   湖南省计算机应用考纲百套卷
1
《计算机编程语言—C语言》第58卷:结构体、共用体及链表 - 知识点训练卷   湖南省计算机应用考纲百套卷
2
《计算机编程语言—C语言》第58卷:结构体、共用体及链表 - 知识点训练卷   湖南省计算机应用考纲百套卷
3
所属专辑
由于学科网是一个信息分享及获取的平台,不确保部分用户上传资料的 来源及知识产权归属。如您发现相关资料侵犯您的合法权益,请联系学科网,我们核实后将及时进行处理。