数据结构里,struct student { char name[20]; char sex[10]; int age; int score; }; 定义结构体后,定义变量、数组赋值正确的是()。
第1题:
有以下说明和定义语句 struct student { int age;char num[8]; struct student stu[3]={{20,"200401"},{21,"200402"},{19,"200403"}}; struct student *p=stu;}; 以下选项中引用结构体变量成员的表达式错误的是
A.(p++)->num
B.p->num
C.(*p).num
D.stu[3].age
第2题:
若有以下定义的语句 struct student {int age; int num;}; struct student stu[3]={{1001,20},{1002,19},{1003,21}}; main() {stmct student *p; p=stu; …} 则以下不正确的引用是
A.(p++)->num
B.p++
C.(*p).num
D.P=&stu.age.
第3题:
有以下结构体说明、变量定义和赋值语句
struct STD
{ char name[10];
int age;
char sex;
} s[5],*ps;
ps=&s[0];
则以下 scanf 函数调用语句中错误引用结构体变量成员的是
A)scanf("%s",s[0].name);
B)scanf("%d",&s[0].age);
C)scanf("%c",&(ps->sex));
D)scanf("%d",ps->age);
第4题:
看这段程序,可是执行。#include <stdio.h>int main(int argc, char *argv[]){ struct info { char name[33]; int age; }; struct info aa[3]={"meng",20,"juan",29,"an",59}; struct info *p=aa; for(int i=0;i<3;i++,p++) printf("%-6s %d\n",p->name,p->age);}将其改成这样:#include <stdio.h>int main(int argc, char *argv[]){ struct info { char name[33]; int age; }; struct info aa[3]={"meng",20,"juan",29,"an",59}; //struct info *p=aa; for(int i=0;i<3;i++,aa++) printf("%-6s %d\n",aa->name,aa->age);}为什么就执行不了呢
第5题:
已知学生记录描述为 struct student { int no; char name[20]; char sex; struct { int year; int month; int day; } birth; }; struct student s;变量s中的“生日”应是“1985年4月4日”,下列对“生日”的正确赋值方式是______。
A.year=1985;month=4;day=4;
B.birth.year=1985;birth.month=4;birth.day=4;
C.s.year=1985;s.month=4;s.day=4;
D.s.birth.year=1985;s.birth.month=4;s.birth,day=4;
第6题:
有以下结构体说明、变量定义和赋值语句 struct STD { char name[10]; int age; char sex; }s[5],*ps; ps=&s[0]; 则以下scanf函数调用语句中错误引用结构体变量成员的是______。
A.scanf("%s",s[0].name);
B.scanf("%d",&s[0].age);
C.scanf("%c",&(ps->sex));
D.scanf("%d",ps->age);
第7题:
有以下说明和定义语句 struct student {int age;char num[8]; }; struct student stu[3]={{20,"200401"},{21,"200402"},{10\9,"200403"}}; struct student*p=stu;以下选项中引用结构体变量成员的表达式错误的是______。
A.(p++)->num
B.p->num
C.*p.num
D.stu[0].age
第8题:
设有如下说明typedef struct{ int number; char class;double score;}student;则以下选项中,能正确定义结构体数组并赋初值的语句是( )。A.student tt[2]={{189,’A’,62},{190,’B’,75}};B.student tt[2]={189,’"A",62,190,"B",75};C.struct tt[2]={{189,’A’},{190,’B’}};D.struct tt[2]={{189,"A",62.5},{190,"B",75.0}};
第9题:
已知学生记录描述为:
struct student
{ int no;
char name[20],sex;
struct
{ int year,month,day;
} birth;
};
struct student s;
设变量s中的"生日"是"1984年11月12日",对"birth"正确赋值的程序段是
A.year=1984;month=11;day=12;
B.s.year=1984;s.month=11;s.day=12;
C.birth.year=1984;birth.month=11;birth.day=12;
D.s.birth.year=1984;s.birth.month=11;s.birth.day=12;
第10题:
此题为判断题(对,错)。