📄 程序8.12:goto语句的错误用法.cpp
字号:
/* 程序8.12:goto语句的错误用法.cpp */
#include<iostream> //包含头文件
#include <cstdlib> //包含头文件
using namespace std; //使用名字空间std
int main()
{
goon:
cout<<"需要一个随机数吗? (y/n) ";
char ans;
cin>>ans;
if(ans == 'n')
goto done;
int ran=rand();
cout<<ran<<endl;
goto goon;
done:
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -