#include<bits/stdc++.h>
#include <stdlib.h>
using namespace std;
bool TreatmentErase=false;
class immense
{
protected:
string LTGp,DCMp;
int LTGn,DCMn;
bool symbol;
public:
immense(){
LTGp="0";//整数部分
DCMp="";//小数部分
LTGn=1,DCMn=0;//整数数位;小数数位
symbol=true;//symbol=true->非负数
}//初始化
void Obtain(void) {
if(!symbol)cout<<'-';
reverse(LTGp.begin(),LTGp.end());
cout<<LTGp;
reverse(LTGp.begin(),LTGp.end());
if(DCMn!=0){
cout<<'.'<<DCMp;
}
}//输入
void rationalize(void){
bool T=true;
for(int i=LTGp.size()-1;i>=0;i--){
if(LTGp[i]>'9'||LTGp[i]<'0'){
if(TreatmentErase){
immense();
break;
}
else LTGp.erase(i,1);
}
if(T&<Gp[i]=='0'&<Gp!="0")LTGp.erase(i,1);
else T=false;
}
if(LTGp=="")LTGp="0";
T=true;
for(int i=DCMp.size()-1;i>=1;i--){
if(DCMp[i]>'9'||DCMp[i]<'0'){
if(TreatmentErase){
immense();
break;
}
else DCMp.erase(i,1);
}
if(T&&DCMp[i]=='0')DCMp.erase(i,1);
else T=false;
}
LTGn=LTGp.size();
DCMn=DCMp.size();
}
void operator=(const immense &T){//赋值(huge)
LTGp=T.LTGp;
DCMp=T.DCMp;
LTGn=T.LTGn;
DCMn=T.DCMn;
symbol=T.symbol;
}
void operator=(string T) {//赋值(string)
if(T[0]=='-'){
symbol=false;
T.erase(0,1);
}
string rdL,rdD;
int split;
for(int i=0;i<T.size();i++){
if(T[i]=='.'){
split=i;
rdL=T.substr(0,split);
rdD=T.substr(split+1,T.size()-split);
goto assignment;
}
}
rdL=T;
rdD="";
assignment: ;
reverse(rdL.begin(),rdL.end());
LTGp=rdL;
DCMp=rdD;
LTGn=rdL.size();
DCMn=rdD.size();
rationalize();
}
bool operator==(immense other){
if(this->symbol==other.symbol)
if(this->DCMp==other.DCMp)
if(this->LTGp==other.LTGp)
return true;
return false;
}
bool operator>(immense other){
if(*this==other)return true;
if(this->symbol>other.symbol)return true;
if(this->symbol<other.symbol)return false;
bool x=this->symbol,y=true;
if(this->LTGn!=other.LTGn){
if(this->LTGn>other.LTGn)y=true;
else y=false;
}
for(int i=this->LTGn-1;i>=0;i--){
if(this->LTGp[i]>other.LTGp[i]){
y=true;
goto finish;
}
if(this->LTGp[i]<other.LTGp[i]){
y=false;
goto finish;
}
}
for(int i=0;i<min(this->DCMn,other.DCMn);i++){
if(this->DCMp[i]-'0'>other.DCMp[i]-'0'){
y=true;
goto finish;
}
if(this->DCMp[i]-'0'<other.DCMp[i]-'0'){
y=false;
goto finish;
}
}
if(this->DCMn>other.DCMn)
y=true;
if(this->DCMn<other.DCMn)
y=false;
finish: ;
return x==y;
}
immense abs(void){
immense k=*this;
k.symbol=true;
return k;
}
immense operator-(void){
immense k;
k.symbol=false;
return k;
}
immense swap(immense &other){
immense k=*this;
*this=other;
other=k;
}
void Add(immense other){
int carry=0,x=0,y=0;
for(int i=other.DCMn-1;i>=0;i--){
if(this->DCMn<i)
this->DCMp+=other.DCMp.substr(this->DCMn),i=this->DCMn;
else{
x=this->DCMp[i]-'0';
y=other.DCMp[i]-'0';
this->DCMp[i]=(x+y+carry)%10+'0';
carry=(x+y+carry)/10;
}
}
for(int i=0;i<other.LTGn;i++){
if(i>this->LTGn){
if(other.LTGp[i]-'0'+carry>9)
this->LTGp+=(other.LTGp[i]-'0'+carry)%10+'0',carry=1;
else
this->LTGp+=other.LTGp[i],carry=0;
}
else{
x=this->LTGp[i]-'0';
y=other.LTGp[i]-'0';
this->LTGp[i]=(x+y+carry)%10+'0';
carry=(x+y+carry)/10;
}
}
if(carry==1)LTGp+='1';
this->LTGn=this->LTGp.size();
this->DCMn=this->DCMp.size();
}
immense Less(immense other){
}
immense Centre(bool AmS,immense other){
immense result=*this;
if(1);
return result;
}
//赋值
};
immense x,y,z;
string a,b;
int main()
{
while(cin>>a>>b)
{
x=a,y=b;
cout<<((x>y)?"true":"false")<<endl;
}
return 0;
}
输出1:
-1 5
false
24 -2
false
输出2:
24 -2
true
为什么会不一样
出问题的是bool operator>(immense other)函数
哪出了问题