Add task2.cpp

main
pv3e4i5aj 4 days ago
parent 5e536cda4b
commit 9575f75e2c

@ -0,0 +1,31 @@
#include <stdio.h>
//定义结构体
struct Student
{
int ID;//学号
float math_grade;
float physics_grade;
float English_grade;
float sum;
};
int main()
{
struct Student information[3];
for(int i=0;i<3;i++)
{
scanf("%d%f%f%f",&information[i].ID,&information[i].math_grade,\
&information[i].physics_grade,&information[i].English_grade);
information[i].sum=information[i].math_grade+\
information[i].physics_grade+information[i].English_grade;
}
for(int i=0;i<3;i++)
{
printf("%d %.1f %.1f %.1f %.1f\n",information[i].ID,\
information[i].math_grade,information[i].physics_grade,\
information[i].English_grade,information[i].sum);
}
}
Loading…
Cancel
Save