异常处理
2025-09-06 09:40:31
发布于:广东
16阅读
0回复
0点赞
#include<bits/stdc++.h>
using namespace std;
int main(){
int n;
cin>>n;
try{
if(n<0){
throw runtime_error("you have a fu shu");
}else{
if(n%2==0){
throw "even";
}else{
throw "odd";
}
}
}
catch(runtime_error& e){
cout<<e.what();
}
catch(const char* s){
cout<<s;
}
return 0;
}
全部评论 6
还可以这样
2025-09-06 来自 广东
066666666
2025-09-06 来自 广东
02025-09-06 来自 广东
02025-09-06 来自 广东
02025-09-06 来自 广东
02025-09-06 来自 广东
0666666666666
2025-09-06 来自 广东
0
有帮助,赞一个