#include<stdio.h>
#include<stdlib.h>
struct XueSheng{
char mingZi[99];
int chengJi;
};
int main(){
int i;
struct XueSheng zuoYe[5];
for(i=0;i<5;++i){
scanf("%s %d",&zuoYe[i].mingZi,&zuoYe[i].chengJi);
}
for(i=0;i<5;++i){
printf("%s %d",zuoYe[i].mingZi,zuoYe[i].chengJi);
}
}
参考:
#include <stdio.h>
struct date {
int year;
int month;
int day;
};
struct student{
int id;
char name[10];
char sex[10];
struct date birthday;
};
int main() {
int i;
struct student stu[5];
for(i=0; i<5; i++){
printf("输入第%d个学生学号,姓名,性别,生日\n", i + 1);
scanf("%d %s %s %d %d %d", &stu[i].id, stu[i].name, stu[i].sex,
&stu[i].birthday.year, &stu[i].birthday.month, &stu[i].birthday.day);
}
printf("输出第3个学生的信息:\n");
printf("%d, %s, %s, %d, %d, %d", stu[3].id, stu[3].name, stu[3].sex,
stu[3].birthday.year, stu[3].birthday.month, stu[3].birthday.day);
return 0;
}