【发布时间】:2012-11-04 23:52:15
【问题描述】:
我正在为学校做一个项目。是这样的:
您应该能够输入 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 公斤。
【问题讨论】:
标签: c++ dynamic-variables