[英]I cannot figure out why this code will not work
what is wrong with my code here?我的代码有什么问题?
int main() {
for(int i=0; i>=5; ++i){
cout << "Hello World! \n";
}
return 0;
}
It is supposed to display "Hello World" 5 times.它应该显示“Hello World”5 次。
All you need to do is replace the >=
with <=
because you are saying that i
is greater than 5 already.你需要做的就是用
<=
替换>=
因为你说i
已经大于 5 了。 Also, with this for loop it will display "Hello World" 6 times because you have i
starting at 0.此外,使用此 for 循环,它将显示“Hello World”6 次,因为您让
i
从 0 开始。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.