这是我到目前为止的代码。我想要做的是让程序显示超过60英寸的儿童数量和身高。该程序现在显示60英寸以上的儿童数量,但我也需要它显示60英寸以上儿童的身高。提前致谢!C++帮助。我有问题得到这个权利
#include <iostream>
using namespace std;
int main()
{
double childHeight[10];
int numChildren = 0;
for (int x = 0; x < 10; x = x + 1)
{
childHeight[x] = 0.0;
}
cout << "You will be asked to enter the height of 10 children." << endl;
for (int x = 0; x < 10; x = x + 1)
{
cout << "Enter the height of child: ";
cin >> childHeight[x];
}
cout << "The number of children over 60 inches are: "<< endl;
for (int x = 0; x < 10; x = x + 1)
{
if (childHeight[x] > 60)
{
numChildren = numChildren + 1;
}
}
cout << numChildren << endl;
system("pause");
return 0;
}
非常感谢您的帮助。 – jgriff 2011-04-13 02:28:25