题解 | #班级成绩输入输出#
班级成绩输入输出
https://www.nowcoder.com/practice/60d96b08e1cb42e38629d54e37eac008
#include <stdio.h> int main() { // 定义一个5行6列的数组 float score[5][6] = {0.0f}; // 定义一个存储各科成绩总和的数组 float sum[5] = {0.0f}; for (int i = 0; i < 5; i++) { for (int j = 0; j < 5; j++) { scanf("%f", &score[i][j]); sum[i] += score[i][j]; } score[i][5] = sum[i]; } for (int i = 0; i < 5; i++) { for (int j = 0; j < 6; j++) { printf("%.1f ", score[i][j]); } printf("\n"); } return 0; }