复习结构体、链表和枚举类型课堂练习第16周.ppt

上传人:牧羊曲112 文档编号:6264876 上传时间:2023-10-11 格式:PPT 页数:14 大小:330.49KB
返回 下载 相关 举报
复习结构体、链表和枚举类型课堂练习第16周.ppt_第1页
第1页 / 共14页
复习结构体、链表和枚举类型课堂练习第16周.ppt_第2页
第2页 / 共14页
复习结构体、链表和枚举类型课堂练习第16周.ppt_第3页
第3页 / 共14页
复习结构体、链表和枚举类型课堂练习第16周.ppt_第4页
第4页 / 共14页
复习结构体、链表和枚举类型课堂练习第16周.ppt_第5页
第5页 / 共14页
点击查看更多>>
资源描述

《复习结构体、链表和枚举类型课堂练习第16周.ppt》由会员分享,可在线阅读,更多相关《复习结构体、链表和枚举类型课堂练习第16周.ppt(14页珍藏版)》请在三一办公上搜索。

1、1,1.有以下定义和语句:struct student int age;int num;struct student stu3=1001,20,1002,19,1003,21;main()struct student*p;p=stu;则以下不正确的引用是。A)(p+)-num B)p+C)(*p).num D)p=&stu.age,D,2,2.有以下结构体定义:struct example int x;int y;v1;则正确的引用或定义是。A)example.x=10;B)example v2;v2.x=10;C)struct v2;v2.x=10;D)struct example v2=1

2、0;,D,3,3.对于如下结构体定义,若对变量person的出生年份进行赋值,正确的赋值是。struct date int year,month,day;struct worklist char name20;char sex;struct date birth;person;A)year=1976 B)birth.year=1976 C)person.birth.year=1976 D)person.year=1976,C,4,7.下述程序运行结果为。#include struct st int n;int*m;*p;void main()int d5=10,20,30,40,50;stru

3、ct st arr5=100,d,200,d+1,300,d+2,400,d+3,500,d+4;p=arr;printf(%dt,+p-n);printf(%dt,(+p)-n);printf(%dn,+(*p-m);/相当于+*(p-m)A)101 200 21 B)101 20 30 C)200 101 21 D)101 101 10,A,5,9.若要利用下面的程序段使指针变量p指向一个存储整型变量的存储单元,则在空格中应填入的内容是。int*p;p=malloc(sizeof(int);int B)int*C)(*int)D)(int*)10.执行下述语句后的结果是。enum week

4、day sun,mon=3,tue,wed,thu;enum weekday day;day=wed;printf(%dn,day);A)5 B)3 C)4 D)编译时出错,D,A,6,4.下面程序的输出结果是。(模拟题)#includevoid main()enum abc green=3,red;char*clr=red,blue,yellow,black,white,green;printf(%s and,clrgreen);printf(%s,clrred);,black and white,7,【例3】已知指针变量head指向单链表表头,下面程序用来统计链表中各个结点的数据项之和,请

5、填空。(模拟题)struct link int data;struct link*next;void main()int k;struct link*head;k=sum(head);printf(%dn,k);sum(【1】)struct link*p;int s;s=head-data;p=head-next;while(p)s+=【2】;p=p-next;return(s);,struct link*head,p-data,8,【例2】以下程序完成链表的输出,请填空。(模拟题)void print(struct stu*head;)struct stu*p;p=head;if(【1】)d

6、o printf(%d,%fn,p-num,p-score);p=p-next;while(【2】);,【1】p!=NULL 或 head!=0,【2】p!=NULL 或 p!=0,9,【例10】以下对枚举类型名的定义中正确的是。(等考1998年4月第50题)A)enum a=one,two,three;B)enum a one=9,two=-1,three;C)enum a=one,two,three;D)enum a one,two,three;【例9】下面程序的输出是。(等考1996年9月第32题)main()enum team my,your=4,his,her=his+10;prin

7、tf(%d%d%d%dn,my,your,his,her);A)0 1 2 3 B)0 4 0 10 C)0 4 5 15 D)1 4 5 15,B,C,10,【例6】有以下程序#include struct node int num;struct node*next;void main()struct node*p,*q,*r;p=(struct node*)malloc(sizeof(struct node);q=(struct node*)malloc(sizeof(struct node);r=(struct node*)malloc(sizeof(struct node);p-num

8、=10;q-num=20;r-num=30;p-next=q;q-next=r;printf(%dn,p-num+p-next-num);程序运行后的输出结果是。(等考2002年9月第46题)A)10 B)20 C)30 D)40,C,11,【例3】若有以下定义:struct link int data;struct link*next;a,b,c,*p,*q;且变量a和b之间已经有如右图所示的链表结构:指针p指向变量a,q指向变量c。能够把c插到a和b之间,并形成新的链表的语句组是。(等考2002年4月第49题)A)a.next=c;c.next=b;B)p.next=q;q.next=p.

9、next;C)p-next=,D,12,1.以下选项中,能定义s为合法的结构体变量的是()A)typedet struct abc B)struct double a;double a;char b10;char b10;s;s;C)struct ABC D)typedef ABC double a;double a;char b10;char b10;ABC s;ABC s;,B,13,2.有以下结构体说明和变量的定义,且如下图所示。指针p指向变量a,指针q指向变量b。则不能把节点b连接到节点a之后的语句是()A)a.next=q;B)p.next=,B,14,9.若有如下定义,则对data中的a成员的正确引用是_。struct skint a;float b;data,*p=A(*p).data.a B(*p).a Cp-data.a D10.C语言共用体类型在任何给定时刻_。A所有成员一直驻留在结构中 B只能有一个成员驻留在结构中C部分成员驻留在结构中 D没有成员驻留在结构中,B,B,

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 生活休闲 > 在线阅读


备案号:宁ICP备20000045号-2

经营许可证:宁B2-20210002

宁公网安备 64010402000987号