为啥对了??
2026-03-10 13:45:41
发布于:浙江
#include<iostream>
#include<stdexcept>
#include<limits>
template<int A,int B>
struct C{static constexpr int v=A+B;};
class S{
private:
int v;
S(int x):v(x){}
public:
static S c(int x){return S(x);}
int g()const{return v;}
S a(const S&o)const{
int a=v,b=o.v;
if(a>0&&b>0){
if(a>stdnumeric_limits<int>max()-b){
throw stdoverflow_error("o");
}
}else if(a<0&&b<0){
if(a<stdnumeric_limits<int>min()-b){
throw stdoverflow_error("u");
}
}
return S(a+b);
}
};
class A{
public:
virtual~A(){}
virtual int a(int a,int b)=0;
};
class B:public A{
public:
int a(int a,int b)override{
return a+b;
}
};
int main(){
int a,b;
stdcin>>a>>b;
if(!stdcin){
return 1;
}
try{
S x=Sc(a);
S y=Sc(b);
S z=x.a(y);
stdcout<<z.g();
}catch(const stdexception&e){
return 1;
}
return 0;
}
全部评论 5
6666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666666=
1周前 来自 浙江
1神秘的⭕
1周前 来自 浙江
1d
3天前 来自 浙江
0d
3天前 来自 浙江
06
1周前 来自 浙江
0




























有帮助,赞一个