Loop statement continue and break 1.for statement

for example:

#include <iostream>
#include <Windows.h>
#include <string>
using namespace std;

int main (void){
int i = 0;
string ret;

for(int i = 0;i < 5; i++){
cout<<"开始第"<<i+1<<"次相亲"<<endl;
cout<<"你有钱吗?";
cin>>ret;
if (ret != "yes"){
cout<<"再见"<<endl;
continue;
}
cout<<"加个微信吧"<<endl;

}
system("pause");
return 0;
}

continue: Exit the next cycle of this cycle is executed here for sentence, if you enter the "no", the next return execution cycle, perform i ++, it is determined i <5.

break;

Guess you like

Origin www.cnblogs.com/Ybossy/p/12094280.html