题解 | #班级成绩输入输出#
班级成绩输入输出
https://www.nowcoder.com/practice/60d96b08e1cb42e38629d54e37eac008
#include <stdio.h> typedef struct{ float data[5]; float sum; }Elemtype; typedef struct student{ Elemtype students[5]; }student; int main() { student S; for(int i=0;i<5;i++){ S.students[i].sum=0; for(int j=0;j<5;j++){ scanf("%f",&S.students[i].data[j]); S.students[i].sum+=S.students[i].data[j]; } } //打印 for(int i=0;i<5;i++){ for(int j=0;j<5;j++){ printf("%.1f ",S.students[i].data[j]); } printf("%.1f\n",S.students[i].sum); } return 0; }