Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/124.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/entity-framework/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ C++;帮助-我可以';我似乎不明白这段代码的最后一部分_C++ - Fatal编程技术网

C++ C++;帮助-我可以';我似乎不明白这段代码的最后一部分

C++ C++;帮助-我可以';我似乎不明白这段代码的最后一部分,c++,C++,我试图让程序显示孩子的当前身高和估计身高 我让它显示第一个孩子的前后身高,但无法让它显示其余孩子的估计身高 如果有人能帮我解决这个问题,我将不胜感激。谢谢 以下是我的代码: #include <iostream> using namespace std; int main() { double height [10]; double chgHeight [10]; for (int x = 0; x < 10; x = x + 1) {

我试图让程序显示孩子的当前身高和估计身高

我让它显示第一个孩子的前后身高,但无法让它显示其余孩子的估计身高

如果有人能帮我解决这个问题,我将不胜感激。谢谢

以下是我的代码:

#include <iostream>

using namespace std;

int main()
{
    double height [10];
    double chgHeight [10];

    for (int x = 0; x < 10; x = x + 1)
    {
        height[x] = 0.0;
        chgHeight[x] = 0.0;
    }

    cout << "You will be asked to enter the heights of ten children."<< endl;

    for (int x = 0; x < 10; x = x + 1)
    {   
        cout << "Enter height of child " << endl;
        cin >> height[x];
    }

    chgHeight[0] = height[0] * .05 + height[0];

    for (int x = 0; x < 10; x = x + 1)
    {   
        cout << "Child " << x+1 << ": Current " << height[x] << " Expected "<< chgHeight[x] << endl;
    }

    system("pause"); 
    return 0;
}
#包括
使用名称空间std;
int main()
{
双高[10];
双通道灯[10];
对于(int x=0;x<10;x=x+1)
{
高度[x]=0.0;
chgHeight[x]=0.0;
}
库特
这一行只计算第一个孩子的估计身高。你还需要将其放入一个循环(将索引更改为你的循环变量)来计算所有10个

chgHeight[0] = height[0] * .05 + height[0];
这一行只计算第一个孩子的估计身高。你还需要将其放入一个循环(将索引更改为你的循环变量)来计算所有10个

chgHeight[0] = height[0] * .05 + height[0];
您只能设置第一个孩子的
chgHeight

编辑:

对于输出,您将遍历数组或高度,该数组或高度由子编号(
x
)索引:

for(int x=0;x<10;x=x+1)
{   
库特
您只能设置第一个孩子的
chgHeight

编辑:

对于输出,您将遍历数组或高度,该数组或高度由子编号(
x
)索引:

for(int x=0;x<10;x=x+1)
{   

cout您没有设置其余孩子的估计身高,只有第一个:

chgHeight[0] = height[0] * .05 + height[0];

把它放在一个循环中。

您没有为其他孩子设置估计高度,只有第一个:

chgHeight[0] = height[0] * .05 + height[0];

把它放在一个循环中。

(如果是的话,那没关系-它应该被标记为这样-这里的人会帮助你,他们只是不会为你做。)布莱恩,这是昨天的家庭作业,但我两周后就要期末考试了,我仍在努力理解这一次。我昨天交了,但这一次的最后一部分是我在代码中显示的。谢谢!我在答案中添加了内容,看看这是否有意义?(如果是的话,那没关系——应该贴上这样的标签——这里的人会帮你的,他们只是不会帮你。)布莱恩,这是昨天的家庭作业,但我两周后就要期末考试了,我还在努力理解这一次。我昨天交了,但这一次的最后一部分是我在代码中显示的。谢谢!我在我的答案中添加了,看看这是否有意义?我试着把它放在一个循环中,但我肯定还是做错了什么。我试过了但我肯定还是做错了什么。