1.break
作用:跳出循环结构和选择结构
1.switch语句中,用于终止case并跳出switch语句;
2.在循环结构中,用于跳出当前循环;
3.在嵌套循环语句中,跳出最近的内层循环语句
代码:
#include <iostream>
using namespace std;
int main()
{
//选择游戏难度(switch)
cout<<"选择游戏难度(1是简单。2是中等,3是困难):"<<endl;
int num;
cin>>num;
switch (num)
{
case (1):cout<<"游戏难度已调为简单"<<endl;
break;
case (2):cout<