给公司建立网站,京东当前网站做的营销活动,jsp商务网站建设,百度一下你就知道移动首页1、continue 语句
作用#xff1a;在循环语句中#xff0c;跳过本次循环中余下尚未执行的语句。继续下一次循环。
注意#xff1a;continue只能用于循环中。 示例#xff1a;
代码#xff1a; //continue的用法 #includeiostream using namespace std; int ma… 1、continue 语句
作用在循环语句中跳过本次循环中余下尚未执行的语句。继续下一次循环。
注意continue只能用于循环中。 示例
代码 //continue的用法 #includeiostream using namespace std; int main() { //如果是奇数则输出否则不输出 for (int i 1; i 100; i) { if (i % 2 0) { continue; } cout i endl; } system(pause); return 0; } 注意continue 并没有使整个循环终止而break会跳出循环。
2、goto语句
作用可以无条件跳转语句。
语法goto 标记
注意一般情况下我们给标记起名时一般都大写。
解释如果标记存在执行到goto语句时会跳转到标记的位置。
示例
代码 //goto语句的使用 #includeiostream using namespace std; int main() { cout 1.hello endl; cout 2.world endl; goto FLAG; cout 3.girl endl; cout 4.boy endl; FLAG: cout 5.hahahaha endl; system(pause); return 0; } 注意在程序中不建议使用goto语句以免造成程序流程混乱。