printf(“%x \\n”,p+9); }
若第一个printf语句输出的是ffca,则第二个printf语句的输出是(B)。 A)ffdd B)ffdc C)ffde D)ffcd
第9章 结构体与共用体
1 选择题
【题1】已知学生记录描述为 struct student {int no;
char name[20]; char set; struct
{int year; int month; int day; }birth; };
struct student s;
设变量s中的“生日”应是“1984年11月11日”,下列对生日的正确赋值方式是(D). A)year=1984; B)birth.year=1984; month=11; birth.month=11; day=11; birth.day=11;
C)s.year=1984; D)s.birth.year=1984; s.month=11; s.birth.month=11; s.day=11; s.birth.day=11;
【题2】当说明一个结构体变量时系统分配给它的内存是(A). A)各成员所需内存量的总和 B)结构中第一个成员所需内存量 C)成员中占内存量最大者所需的容量 D)结构中最后一个成员所需内存量
【题3】以下对结构体类型变量的定义中不正确的是(D). A)#define STUDENT struct student STUDENT {int num; float age;
}std1;
B)struct student {int num; float age; }std1;
C)struct {int num; float age; }std1;
D)struct int num; float age; }student;
struct student std1;
【题4】设有以下说明语句 struct stu {int a; float b; }stutype;
则下面的叙述不正确的是(C). A)struct是结构体类型的关键字
B)struct stu是用户定义的结构体类型 C)stutype是用户定义的结构体类型名 D)a和b都是结构体成员名
【题5】C语言结构体类型变量在程序执行期间(A).. A)所有成员一直驻留在内存中 B)只有一个成员驻留在内存中 C)部分成员驻留在内存中 D)没有成员驻留在内存中
【题6】在16位IBM-PC机上使用C语言,若有如下定义: struct data {int i; char ch; double f; }b;
则结构变量b占用内存的字节数是(D). A)1 B)2 C)3 D)4
题【7】以下程序的运行结果是(A). #include “stdio.h” main()
{struct data
{int year,month,day; }today;
printf(“%d\\n”,sizeof(struct data)); }
A)6 B)8 C)10 D)12
【题8】根据下面的定义,能打印出字母M的语句是(D). Struct person{char name[9]; int age; };
struct person class[10]={“John”,17, “Paul”,19, “Mary”,18, “adam”,16 };
A)printf(“%c\\n”,class[3].name); B)printf(“%c\\n”,class[3].name[1]); C)printf(“%c\\n”,class[2].name[1]); D)printf(“%c\\n”,class[2].name[0]);
【题9】下面程序的运行结果是(D). main() {
struct cmplx {int x; int y;
} cnum[2]={1,3,2,7};
printf(“%d\\n”,cnum[0].y/cnum[0].x*cnum[1].x); }
A)0 B)1 C)3 D)6
【题10】 若有以下定义和语句; struct student {int age; int num ; };
struct student stu [3]={{1001,20 },{1002,19},{1003,21}}; main()
{struct student *p; p=stu; ?.. }
则以下不正确的引用是(D)。 A)(P++)—》 num B)p++
C)(*p).num D)p=&stu.age
【题11】以下scanf函数调用语句中对结构体 变量成员的不正确引用是(D)。 Stuct pupil
{char name[20 ]; int age ; int sex; }pup[5,]*p; p=pup;
A) scanf(“%s”,pup[0].name); B) scanf(“”%d),&pup[0].age; C) scanf(“%d”,&sex));?(p D) scanf(“%d”,P->age);
【题12】有以下定义和语句,则以下引用形式不合法的是(D)。 Struct s {int i1;
struct s*i2,i0; };
static struct s a[3 ]={2,&a[1],?\\0?,4,%a[2],&a[0],6,?\\0?,&a[1]}, *ptr; ptr=a;
A) ptr->i1++ B)*ptr->i2 C)++ptr->i0 D)ptr->i1
【题13】设有如下定义: struct sk {int n; float x; }data,*p;
若要使P指向data中的n域, 正确的负值语句的是(C)。 A) p=&data.n; B) *p=data.n;
C) p=(struct sk*)&data.n; D) p=(struct sk*)data.n;
【题14】若哟于以下说明和语句: struct student {int age; int num; }std,*p; p=&std;
则以下对结构体变量std中成员age的引用方式不正确的是(D)。 A)std.age B)p->age
C)(*p).age D)*p.age
【题15 】若以下程序段: struct dent { int n; int*m; };
int a=1, b=2,c=3;
struct dent s[3]={{101<&a},{102<&b},{103,&c}; main() {
struct dent *p; p=s; ?.. }
则以下表达中值为2的是--D---。 A)(p++)->m B)*(P++)->m C)(*p).m D)*(++p)->m
【题16】若有以下说明和语句,则 对中域的正确引用方式是(D)。 Struct pupil
{char name [20 ; int sex; }pup,*p; p=&pup;
A)p.pup.sex B)p->pup.sex C)(*p).pup.sex D)(*p).sex
【题17】设有以下语句: struct st {int n;
struct st *next; };
static struct st a[3 ] ={5,&a[1] ,7,&a[2],9,?\\0?},*p; p=&a=[0];
则以下表达式的值为6的是(D)。 A)p++->n B)p->n++ C)(*P).n++ D)++p->n
【题18】以下程序的输出结果是(C)。 Struct stu {int x; int*y; } *p;