举个例子:
#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 :退出本次循环执行下一次循环,在这里的for语句中,如果输入了“no”,返回执行下一个循环,先执行i++,在判断i<5.
break;
原文地址:https://www.cnblogs.com/Ybossy/p/12094280.html
时间: 2024-10-20 19:10:50