#include <iostream>
#include <iomanip>
#include "array.h"
using namespace std;
#include <iomanip>
#include "array.h"
using namespace std;
int main()
{
int n;
double average,total = 0;
cout << "请输入学生人数:";
cin >> n;
Array<float> score(n);
for (int i=0; i<n; i++)
{
cout << "请输入第" << i+1 <<"个学生的课程A成绩(0~100):";
cin >> score[i];
total += score[i];
}
average = total/n;
cout << "平均成绩为" << setprecision(4) << average << endl;
return 0;
}
本文介绍了一个简单的C++程序,该程序用于输入一组学生的分数,并计算这些分数的平均值。程序首先提示用户输入学生人数,然后逐一录入每个学生的成绩,最后计算并输出所有学生的平均成绩。

1万+

被折叠的 条评论
为什么被折叠?



