假设已构造好struct student数据类型; 则函数头void fun ( struct student stu[ ] ) 完全等价于void fun ( struct student *stu )
举一反三
- 编写input()函数输入5个学生的数据记录。(用结构体设计,学生记录中包括学号、姓名、四门课程成绩).【1】、【2】分别填写的是( )。 #include#define N 5 struct student { char num[6]; char name[8]; int score[4]; } stu[N]; void input(struct student stu[]); void print(struct student stu[]); main() { input(stu); } void input(struct student stu[]) { int i,j; for(i=0;i A: stu[i].num B: stu[i+1].num C: stu[i].name D: stu[j].name
- 下列程序的输出结果第一行是_____,第二行是_______。 #include [iostream] #include [cstring] #include [iomanip] using namespace std; struct student { int num; char name[20]; double score; }; void fun(struct student *s); int main() { struct student stu={12345, "Zhangwei", 98.0}; cout[<stu.num<<","<<stu.name<<","<<stu.score<<endl; fun(&stu); cout<<stu.num<<","<<stu.name<<","<<stu.score<<endl; return 0; } void fun(struct student *s) { s-]num=23456; strcpy(s->name, "Liming"); s->score=88; }
- 有以下定义和语句: struct student { int age; int num; }; struct student stu[3]={{1001,20},{1002,19},{1003,21}}; void main() { struct student *p; p=stu; …… } 则以下不正确的引用是
- 下列选项中不能够定义一个结构体类型变量stu的是 。 A: struct student { int num; int age; } stu; B: struct student { int num; int age; }; student stu; C: struct {int num; int age; } stu; D: struct student {int num; int age; }; struct student stu;
- 已知有typedef struct student STU;下面和struct student s1;等效的是?() A: STU s1; B: student STU s1; C: struct STU s1; D: typedef STU s1;