這是我到目前爲止的代碼。我想要做的是讓程序顯示超過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