简体   繁体   English

我无法弄清楚为什么此代码不起作用

[英]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.

相关问题 运行此代码时,Dev C ++不断崩溃。 我不知道为什么 - Dev C++ keeps crashing when I run this code. I cannot figure out why 我的最后一个正则表达式不起作用,但是我无法弄清楚为什么 - My last regular expression won't work but i cannot figure out the reason why 每当我运行C ++中的乘法矩阵代码时,它都会不断崩溃。 无法找出原因 - Multiplication Matrix Code in C++ keeps crashing whenever I run it. Cannot figure out why 我不明白为什么for循环在此代码上不起作用 - I can't figure out why for-loop doesn't work on this code 我不知道为什么我的文件没有写出来 - I cannot figure out why my file is not writing out 无法弄清楚如何执行此代码 - Cannot figure out how to do this code 无法弄清楚为什么这个函数返回零 - Cannot figure out why this function returns zero 无法解析的外部符号,无法找出原因 - Unresolved external symbol, cannot figure out why 细分错误已解决,但无法找出原因 - The segmentation fault is resolved, but cannot figure out why 这段代码是如何工作的,是反转字符串的很短的方法,它可以工作,但是我不知道如何 - How this code work, really short way to reverse a string, It work, but I can't figure out how
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM