diff --git a/task2.cpp b/task2.cpp new file mode 100644 index 0000000..0dfa320 --- /dev/null +++ b/task2.cpp @@ -0,0 +1,31 @@ +#include +//定义结构体 +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); + } +} +