现有有N个学生的数据记录,每个记录包括学号、姓名、三科成绩。 编写一个函数input,用来输入一个学生的数据记录。 编写一个函数print,打印一个学生的数据记录。 在主函数调用这两个函数,读取N条记录输入,再按要求输出。 N<100
Input
学生数量N占一行 每个学生的学号、姓名、三科成绩占一行,空格分开。
Output
每个学生的学号、姓名、三科成绩占一行,逗号分开。
Sample Input
2
a100 zhblue 70 80 90
b200 newsclan 90 85 75
Sample Output
a100,zhblue,70,80,90
b200,newsclan,90,85,75
#include<stdio.h>
//定义一个结构体数组
struct student
{
char id[110];
char name[110];
int x;
int y;
int z;
}a[20];
int main()
{
int i,n;
scanf("%d",&n);
//循环对结构体数组输入数据
for(i=0;i<n;i++)
{
scanf("%s",a[i].id);
scanf("%s",a[i].name);
scanf("%d",&a[i].x);
scanf("%d",&a[i].y);
scanf("%d",&a[i].z);
}
for(i=0;i<n;i++)
{
printf("%s,",a[i].id);
printf("%s,",a[i].name);
printf("%d,",a[i].x);
printf("%d,",a[i].y);
printf("%d\n",a[i].z);
}
return 0;
}