qfedu-cpp-level/day8/d1.cpp

22 lines
285 B
C++
Raw Normal View History

2023-08-02 19:23:29 +08:00
// 抛出异常
#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;
}