4.3跳转语句
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;
}
int main(){
for(int i=0;i<=10;i++)
{
if(i == 5)
{
break;
}
cout<<i<<endl;
}
system("pause");
return 0;
}
for(int i = 0;i<10;i++)
{
for(int j = 0; j<10;j++)
{
if(j == 5)
{
break;
}
cout<<"*"<<" ";
}
cout<<endl;
}
4.3.2continue语句
int main(){
for(int i = 0;i<=100;i++)
{
if(i%2 == 0)
{
continue;//可以筛选条件,执行到此就不在向下执行
}
cout<<i<<endl;
}
system("pause");
return 0;
}
4.3.3goto语句
int main(){
cout<<"1"<<endl;
cout<<"2"<<endl;
goto FLAG;
cout<<"3"<<endl;
cout<<"4"<<endl;
FLAG:
cout<<"5"<<endl;
system("pause");
return 0 ;
}