C/C++の宿題を片付けます 122代目at TECH
C/C++の宿題を片付けます 122代目 - 暇つぶし2ch240:デフォルトの名無しさん
09/01/18 22:11:01
>>237
(3)
#include<iostream>
#include<algorithm>
#include<numeric>
#include<vector>
int main() {
int num, score;
std::cout << "Number of students = ";
std::cin >> num;
std::vector<int> scores;
for (int i = 0; i < num; i ++) {
std::cout << "Student" << 1+i << "'s score = ";
std::cin >> score;
scores.push_back(score);
}
std::cout << "-----\n";
std::cout << "The highest score is " << *std::max_element(scores.begin(), scores.end()) << ".\n";
std::cout << "The lowest score is " << *std::min_element(scores.begin(), scores.end()) << ".\n";
std::cout << "Average score is " << std::accumulate(scores.begin(), scores.end(), 0) / scores.size() << "." << std::endl;
return 0;
}


次ページ
続きを表示
1を表示
最新レス表示
レスジャンプ
類似スレ一覧
スレッドの検索
話題のニュース
おまかせリスト
オプション
しおりを挟む
スレッドに書込
スレッドの一覧
暇つぶし2ch