#include<iostream>
using namespace std;
int main()
{
/*
break出现时机
1.出现在switch语句中,作用是终止case并跳出switch
2.出现在循环语句中,作用是跳出当前的循环语句
3.出现在嵌套循环中,跳出最近的内层循环语句*/
//1.switch
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;
}
//2.循环语句
for (int i = 0; i < 10; i++)
{
//如果i=5退出循环,不再打印
if (i == 5)
{
break;
}
cout << i << endl;
}
//3.出现在嵌套循环语句中
for (int i = 0; i < 10; i++)
{
for (int j = 0; j < 10; j++)
if (j == 5)
{
break;
}
cout << "*";
}
system("pauase");
return 0;
}