繁体   English   中英

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

[英]I cannot figure out why this code will not work

我的代码有什么问题?

int main() {
  for(int i=0; i>=5; ++i){

   cout << "Hello World! \n";

  }

  return 0;
}

它应该显示“Hello World”5 次。

你需要做的就是用<=替换>=因为你说i已经大于 5 了。 此外,使用此 for 循环,它将显示“Hello World”6 次,因为您让i从 0 开始。

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM