22 lines
285 B
C++
22 lines
285 B
C++
|
// 抛出异常
|
||
|
#include <iostream>
|
||
|
|
||
|
using namespace std;
|
||
|
|
||
|
int div(int a, int b)
|
||
|
{
|
||
|
if (b == 0)
|
||
|
{
|
||
|
throw "除数不能为0";
|
||
|
}
|
||
|
return a / b;
|
||
|
}
|
||
|
|
||
|
int main()
|
||
|
{
|
||
|
cout << "-----aaaaa-----" << endl;
|
||
|
int ret = div(20, 0);
|
||
|
cout << ret << endl;
|
||
|
return 0;
|
||
|
}
|