跳转语句(个人学习笔记黑马学习)

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;
}
相关推荐
三水不滴3 分钟前
计网:输入网址到网页显示
经验分享·笔记·计算机网络
坚果派·白晓明4 分钟前
在鸿蒙设备上快速验证由lycium工具快速交叉编译的C/C++三方库
c语言·c++·harmonyos·鸿蒙·编程语言·openharmony·三方库
小镇敲码人11 分钟前
深入剖析华为CANN框架下的Ops-CV仓库:从入门到实战指南
c++·python·华为·cann
YCY^v^41 分钟前
JeecgBoot 项目运行指南
java·学习
云小逸1 小时前
【nmap源码解析】Nmap OS识别核心模块深度解析:osscan2.cc源码剖析(1)
开发语言·网络·学习·nmap
张张努力变强1 小时前
C++ STL string 类:常用接口 + auto + 范围 for全攻略,字符串操作效率拉满
开发语言·数据结构·c++·算法·stl
小镇敲码人1 小时前
探索CANN框架中TBE仓库:张量加速引擎的优化之道
c++·华为·acl·cann·ops-nn
平安的平安1 小时前
面向大模型算子开发的高效编程范式PyPTO深度解析
c++·mfc
June`1 小时前
muduo项目排查错误+测试
linux·c++·github·muduo网络库
JustDI-CM1 小时前
AI学习笔记-提示词工程
人工智能·笔记·学习