我正在为学校做一个项目。情况是这样的:
您应该能够为n名学生输入权重。计算学生的平均体重并输出有多少学生的体重低于 65 公斤。
到目前为止,我有这个 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 个新的权重变量。
编辑:
我可以计算平均体重,找出有多少学生的体重低于 65 公斤。只有我坚持定义将添加多少学生的变量数量。计算学生的平均体重并输出有多少学生的体重低于 65 公斤。