2.6重学C++之【跳转语句continue和goto】
#include<iostream>
using namespace std;
int main(){
//3 跳转语句
//3-2 continue
//循环语句中,跳过本次循环中余下未执行的语句,直接执行下一次循环
//区别:break会直接退出循环而不再执行循环
for (int i=0; i<=100; i++){
if (i%2==0){ //仅奇数输出,偶数跳过
continue; //可用作筛选条件
}
cout << i << endl;
}
//3-3 goto
//不推荐使用,易混乱结构,但见了要懂
cout << "1..." << endl;
cout << "2..." << endl;
goto FLAG;
cout << "3..." << endl;
cout << "4..." << endl;
FLAG:
cout << "5..." << endl;
cout << "6..." << endl;
return 0;
}