133.throw机制 抛出类类型
2024-10-10 08:10:33
#include <iostream>
using namespace std; //try尝试执行,抛出throw,throw之后语句不再执行
//catch处理throw的异常 void main()
{
float fl1, fl2;
cin >> fl1 >> fl2; //尝试执行,抛出类型检测
try
{
if (fl2 < 0.0000001)
{
throw ;
}
else if (fl1 < 0.000001)
{
throw ;
} float fl3 = fl1 / fl2;
cout << fl3 << endl;
}
//定义类型,检测判断是什么错误
catch (int code)
{
if (code == )
{
cout << "fl2太小" << endl;
}
else if (code == )
{
cout << "fl2太小" << endl;
}
} cin.get();
cin.get();
}
最新文章
- java Io文件输入输出流 复制文件
- WinForm窗体代码结构优化
- MySQL(三) —— 约束以及修改数据表
- genymotion是一款完全超越BlueStacks
- linux网卡绑定
- CodeForces 711D Directed Roads (DFS判环+计数)
- cf509A Maximum in Table
- iOS开发者需要的5款排版工具
- EF批量插入(转)
- for循环-0,1,1,2,2可以组成多少个不重复的五位数?
- django restframework 跨域访问
- eclipse 报错问题:java.lang.ClassNotFoundException:
- kubernets kubevirt 分析
- 多元高斯分布(The Multivariate normal distribution)
- git上传中的排除的配置文件, git实际的操作代码;
- Three.js基础探寻三——透视投影照相机
- Codeforces Round #372 (Div. 1) A. Plus and Square Root 数学题
- 在Linux下用make指令编译进度条程序。
- thymeleaf 配置
- 20165203迭代和JDB测试