zoukankan      html  css  js  c++  java
  • hdu2054 A==B

    View Code
    include<iostream>
    #include<cstdio>
    #include<string>
    using namespace std;
    int main()
    {
        string a,b;
        while(cin>>a>>b)
        {
            if(a[0]=='+'&&a[1]=='0'&&a.size()==2)a="0";
            if(a[0]=='-'&&a[1]=='0'&&a.size()==2)a="0";
            if(b[0]=='+'&&b[1]=='0'&&b.size()==2)b="0";
            if(b[0]=='-'&&b[1]=='0'&&b.size()==2)b="0";
            if(a==b&&b=="0")continue;
            if(a[0]=='+')
            {
                a.erase(0,1);
            }
            while(a[0]=='0'&&a[1]!='.'&&a.size()!=1)
            {
                a.erase(0,1);
            }
            while(a[0]=='-'&&a[1]=='0'&&a[2]!='.')
            {
                a.erase(1,1);
            }
            while((a.find('.')!=string::npos)&&a[a.size()-1]=='0')
            {
                a.erase(a.size()-1,1);
            }
            if(a[a.size()-1]=='.')a.erase(a.size()-1,1);
            
            if(b[0]=='+')
            {
                b.erase(0,1);
            }
            while(b[0]=='0'&&b[1]!='.'&&a.size()!=1)
            {
                b.erase(0,1);
            }
            while(b[0]=='-'&&b[1]=='0'&&b[2]!='.')
            {
                b.erase(1,1);
            }
            while((b.find('.')!=string::npos)&&b[b.size()-1]=='0')
            {
                b.erase(b.size()-1,1);
            }
            if(b[b.size()-1]=='.')b.erase(b.size()-1,1);
            //cout<<a<<" "<<b<<endl;
            if(a==b)cout<<"YES"<<endl;
            else cout<<"NO"<<endl;
            
            
        }
    }
  • 相关阅读:
    导出htmlcleaner
    备份
    本地win7搭建SVN
    nutch 导入ecl
    linux 启动nutch
    c++中的构造函数前加上explicit
    string::erase的使用心得
    C++的static关键字(转载)
    Boot Trigger
    strtol()详解
  • 原文地址:https://www.cnblogs.com/zlyblog/p/3033026.html
Copyright © 2011-2022 走看看