题目描述
定义一个结构体,输入输出两个学生的数据记录。
输入
输入占两行,分别输入两个学生的数据
输出
输出占两行,输出两个学生的数据
输入样例
Tom 18 85.5
Bob 19 90.0
输出样例
Tom 18 85.50
Bob 19 90.00
#include <stdio.h>
typedef struct{
char name[20];
int age;
float score;
}Student;
int main()
{
Student stu[2];
int i;
for(i=0;i<2;i++)
{
scanf("%s",stu[i].name);
scanf("%d",&stu[i].age);
scanf("%f",&stu[i].score);
}
for(i=0;i<2;i++)
{
printf("%s %d %.2f\n",stu[i].name,stu[i].age,stu[i].score);
}
return 0;
}