私は学校のプロジェクトに取り組んでいます。これが当てはまります:
n人の生徒の重みを入力できるはずです。生徒の平均体重を計算し、体重が65kg未満の生徒の数を出力します。
これで、C++ソースのサンプルができました。
#include <cstdlib>
#include <iostream>
using namespace std;
int main(int argc, char *argv[])
{
int number_of_students;
cout << "How many students would you like to add?: ";
cin >> number_of_students;
cout << endl;
cout << endl;
cout << "--------------------------------------------" << endl;
cout << "---------- ENTER STUDENT'S WEIGHT ----------" << endl;
cout << "--------------------------------------------" << endl;
cout << endl;
system("PAUSE");
return EXIT_SUCCESS;
}
私は現在立ち往生しているので、これは基本的に何もありません。ユーザーがたとえば6人の生徒を入力したときに、たとえば6つの新しい重み変数を誰に追加できるかわかりません。
編集:
平均体重を計算して、体重が65kg未満の生徒の数を見つけることができます。追加される生徒の数の変数の数を定義することに固執しているのは私だけです。生徒の平均体重を計算し、体重が65kg未満の生徒の数を出力します。