ch21_2.cpp
资源名称:c.rar [点击查看]
上传用户:puke2000
上传日期:2022-07-25
资源大小:912k
文件大小:0k
源码类别:
C#编程
开发平台:
Visual C++
- //**********************
- //** ch21_2.cpp **
- //**********************
- #include <iostream.h>
- double Div(double, double );
- void main()
- {
- try{
- cout <<"7.3/2.0=" <<Div(7.3, 2.0) <<endl;
- cout <<"7.3/0.0=" <<Div(7.3, 0.0) <<endl;
- cout <<"7.3/1.0=" <<Div(7.3, 1.0) <<endl;
- }
- catch(double)
- {
- cout <<"except of deviding zero.n";
- }
- cout <<"That is ok. n";
- }
- double Div(double a, double b)
- {
- if(b==0.0)
- throw b;
- return a/b;
- }