| Run ID | 作者 | 问题 | 语言 | 测评结果 | 时间 | 内存 | 代码长度 | 提交时间 |
|---|---|---|---|---|---|---|---|---|
| 85102 | sh25_wangtaojie | 期末成绩-二维数组 | C++ | 解答错误 | 1 MS | 244 KB | 1169 | 2026-03-06 14:59:57 |
#include <iostream> #include <iomanip> using namespace std; int main() { const int STUDENTS = 3; const int SUBJECTS = 2; // 创建二维数组存储学生成绩 int scores[STUDENTS][SUBJECTS]; // 输入学生成绩 for (int i = 0; i < STUDENTS; i++) { for (int j = 0; j < SUBJECTS; j++) { cin >> scores[i][j]; } } // 计算并输出每个学生的总分 for (int i = 0; i < STUDENTS; i++) { int total = 0; for (int j = 0; j < SUBJECTS; j++) { total += scores[i][j]; } cout << total; if (i < STUDENTS - 1) { cout << " "; } } cout << endl; // 计算并输出每门科目的平均分(向下取整) for (int j = 0; j < SUBJECTS; j++) { int subjectTotal = 0; for (int i = 0; i < STUDENTS; i++) { subjectTotal += scores[i][j]; } int average = subjectTotal / STUDENTS; cout << average; if (j < SUBJECTS - 1) { cout << " "; } } cout << endl; return 0; }