题解 | #班级成绩输入输出#
班级成绩输入输出
https://www.nowcoder.com/practice/60d96b08e1cb42e38629d54e37eac008
#include <stdio.h> int main() { float a, sum = 0; int n = 0; //简单题型不需要那么难吧,节约时间和空间复杂度远比算法复杂度好 while (scanf("%f", &a) != EOF) { printf("%.1f ", a); sum += a; n++; if (n == 5) { printf("%.1f\n",sum); sum = 0; n = 0; } } return 0; }