1 #include<iostream> 2 #include<string> 3 using namespace std; 4 string s[2]; 5 void shape(int n){ 6 int i,pj=0,len=s[n].length(),p=0; 7 if(s[n][0]==‘-‘) 8 p=1; 9 for(i=0;i<len;i++) 10 if(s[n][i]==‘.‘){ 11 pj=1; 12 break; 13 } 14 if(pj){ 15 while(s[n][len-1]==‘0‘) 16 s[n].erase(--len,1); 17 if(s[n][len-1]==‘.‘) 18 s[n].erase(--len,1); 19 } 20 while(s[n][p]==‘0‘){ 21 if(len>p+1){ 22 s[n].erase(p,1); 23 len--; 24 } 25 else 26 break; 27 } 28 if(s[n][p]==‘.‘) 29 s[n].insert(p,"0"); 30 if(s[n]=="-0") 31 s[n]="0"; 32 } 33 int main(){ 34 ios::sync_with_stdio(0); 35 cin.tie(0);cout.tie(0); 36 while(cin>>s[0]>>s[1]){ 37 shape(0); 38 shape(1); 39 if(s[0]==s[1]) 40 puts("YES"); 41 else 42 puts("NO"); 43 } 44 return 0; 45 }
原文:https://www.cnblogs.com/stelayuri/p/12208042.html