下面是一个C++程序,可以输入五个学生的三门成绩并输出:

#include <iostream>
using namespace std;

int main()
{
    const int NUM_STUDENTS = 5;
    const int NUM_SUBJECTS = 3;

    int scores[NUM_STUDENTS][NUM_SUBJECTS];

    // Input scores for each student
    for (int i = 0; i < NUM_STUDENTS; i++) {
        cout << "Enter scores for student " << i+1 << endl;
        for (int j = 0; j < NUM_SUBJECTS; j++) {
            cout << "Enter score for subject " << j+1 << ": ";
            cin >> scores[i][j];
        }
    }

    // Output scores for each student
    for (int i = 0; i < NUM_STUDENTS; i++) {
        cout << "Scores for student " << i+1 << ": ";
        for (int j = 0; j < NUM_SUBJECTS; j++) {
            cout << scores[i][j] << " ";
        }
        cout << endl;
    }

    return 0;
}

这个程序使用了一个二维数组 scores 来存储每个学生的三门成绩。在输入阶段,程序通过嵌套的 for 循环来逐个输入每个学生的成绩;在输出阶段,程序同样通过嵌套的 for 循环来逐个输出每个学生的成绩

请写一个输入五个学生的三门成绩并输出的c++程序

原文地址: https://www.cveoy.top/t/topic/gsqc 著作权归作者所有。请勿转载和采集!

免费AI点我,无需注册和登录