break语句
cpp#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; }
cpp#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; }
cpp#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 语句
如果是奇数输出,偶数不输出
cpp#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语句
cpp#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; }
跳转语句(个人学习笔记黑马学习)
寻心的无心者2023-08-29 14:01
相关推荐
kkk_皮蛋21 分钟前
力扣773:滑动谜题哦豁灬38 分钟前
NCNN 学习(2)-MatLength-vision40 分钟前
Linux入门学习:Linux调试器gdb使用float_com1 小时前
【STL】 set 与 multiset:基础、操作与应用茶馆大橘2 小时前
(黑马点评)八、实现签到统计和uv统计临沂堇2 小时前
CCF刷题计划——训练计划(反向拓扑排序)铁匠匠匠2 小时前
【C总集篇】第八章 数组和指针猿饵块2 小时前
cmake--get_filename_component森龙安2 小时前
string类,vector<T>,iterator迭代器,C风格字符串,数组秋邱2 小时前
C++: 类和对象(上)