//练习6:改为用try,throw,catch处理除数为零异常程序
#include
#include
using namespace std;
int Div(int x,int y); //函数Div的原型
int main()
{ cout<<"6/3="<<Div(7,3)<<endl;
cout<<"5/0=";
cout<<Div(5,0)<<endl;
return 0;
}
int Div(int x,int y) //定义函数Div
{ if (y==0)
{ cout<<"除数为0,错误!"<<endl;
exit (0);
}
return x/y;
}