break语句
#include <iostream> using namespace std; int main() { cout << "请选择副本难度" << endl; cout << "1、普通" << endl; cout << "2、中等" << endl; cout << "3、困难" << endl; int select = 0; cin >> select; switch (select) { case 1: cout << "您选择的是普通难度" << endl; break; case 2: cout << "您选择的是中等难度" << endl; break; case 3: cout << "您选择的是困难难度" << endl; break; default: break; } system("pause"); return 0; }
文章来源地址https://www.toymoban.com/news/detail-680093.html
#include <iostream> using namespace std; int main() { for (int i = 0; i < 10; i++) { if (i == 5) { break; } cout << i << endl; } system("pause"); return 0; }
#include <iostream> using namespace std; int main() { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) { if (j == 5) { break; } cout << "* "; } cout << endl; } system("pause"); return 0; }
continue 语句
如果是奇数输出,偶数不输出
#include <iostream> using namespace std; int main() { for (int i = 0; i <= 100; i++) { if (i % 2 == 0) { continue; } cout << i << endl; } system("pause"); return 0; }
goto语句
#include <iostream> using namespace std; int main() { cout << "1、xxxxx" << endl; cout << "2、xxxxx" << endl; goto FLAG; cout << "3、xxxxx" << endl; FLAG: cout << "4、xxxxx" << endl; cout << "5、xxxxx" << endl; system("pause"); return 0; }
文章来源:https://www.toymoban.com/news/detail-680093.html
到了这里,关于跳转语句(个人学习笔记黑马学习)的文章就介绍完了。如果您还想了解更多内容,请在右上角搜索TOY模板网以前的文章或继续浏览下面的相关文章,希望大家以后多多支持TOY模板网!