Run ID | 作者 | 问题 | 语言 | 测评结果 | Time | Memory | 代码长度 | 提交时间 |
---|---|---|---|---|---|---|---|---|
119655 | 蔡胤泽 | 18统计成绩 | C++ | Accepted | 1 MS | 276 KB | 821 | 2025-05-18 11:22:50 |
#include <iostream> #include <iomanip> // 用于控制输出格式 using namespace std; int main() { int n; cin >> n; int scores[100]; // 假设最多100名学生 int sum = 0; int max_score = 0; int min_score = 100; // 初始设为最高可能值 for (int i = 0; i < n; ++i) { cin >> scores[i]; sum += scores[i]; if (scores[i] > max_score) { max_score = scores[i]; } if (scores[i] < min_score) { min_score = scores[i]; } } double average = static_cast<double>(sum) / n; // 输出总分、平均分(保留2位小数)、最高分、最低分 cout << sum << " " << fixed << setprecision(2) << average << " " << max_score << " " << min_score << endl; return 0; }