7章4节用break来跳出while

来源:互联网 发布:忧郁眼神知乎 编辑:程序博客网 时间:2024/05/18 02:02

#include <iostream>

int main()
{
 int counter=0;

 while(true)
 {
  counter++;
  if(counter>10)
   break;//break 和 continue 的区别 前者是跳出 后者是跳转到程序的开头
 }
 std::cout  << " counter is " <<counter <<"/n";

 return 0;
}