处理后再判断即可,处理过程注意考虑全面。

#include<iostream>
#include<string>
using namespace std;
string s[2];
void shape(int n){
    int i,pj=0,len=s[n].length(),p=0;
    if(s[n][0]=='-')
        p=1;
    for(i=0;i<len;i++)
        if(s[n][i]=='.'){
            pj=1;
            break;
        }
    if(pj){
        while(s[n][len-1]=='0')
            s[n].erase(--len,1);
        if(s[n][len-1]=='.')
            s[n].erase(--len,1);
    }
    while(s[n][p]=='0'){
        if(len>p+1){
            s[n].erase(p,1);
            len--;
        }
        else
            break;
    }
    if(s[n][p]=='.')
        s[n].insert(p,"0");
    if(s[n]=="-0")
        s[n]="0";
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    while(cin>>s[0]>>s[1]){
        shape(0);
        shape(1);
        if(s[0]==s[1])
            puts("YES");
        else
            puts("NO");
    }
    return 0;
}

 

相关文章:

  • 2022-01-31
  • 2021-05-31
  • 2021-11-04
  • 2022-02-19
  • 2021-07-19
  • 2022-12-23
  • 2021-07-21
  • 2022-12-23
猜你喜欢
  • 2021-12-08
  • 2021-12-21
  • 2021-05-19
  • 2022-02-03
  • 2021-05-31
  • 2021-05-26
  • 2021-10-15
相关资源
相似解决方案