zoukankan      html  css  js  c++  java
  • HDU 2054 A == B ?

    http://acm.hdu.edu.cn/showproblem.php?pid=2054

    Problem Description
    Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".
     
    Input
    each test case contains two numbers A and B.
     
    Output
    for each case, if A is equal to B, you should print "YES", or print "NO".
     
    Sample Input
    1 2
    2 2
    3 3
    4 3
     
    Sample Output
    NO
    YES
    YES
    NO
     
    题解:不需要考虑前置零 把小数点后面多余的 0 去掉再进行比较就可以
     
    代码:
    #include <bits/stdc++.h>
    using namespace std;
    
    const int maxn=1e5+10;
    char a[maxn],b[maxn];
    
    void rep(char s[]) {
        int len=strlen(s);
        int flag=0;
        for(int i=0;i<len;i++) {
            if(s[i]=='.') {
                flag=1;
                break;
            }
        }
        if(flag) {
            for(int i=len-1;i>=0;i--) {
                if(s[i]=='0') s[i]='';
                else break;
                len--;
            }
            if(s[len-1]=='.') s[len-1]='';
        }
    }
    
    int main() {
        while(~scanf("%s%s",a,b)) {
             rep(a);
             rep(b);
          if(strcmp(a,b))
             printf("NO
    ");
          else
             printf("YES
    ");
        }
        return 0;
    }
    

      

  • 相关阅读:
    你好,明天
    一句话实现星级评价
    react路由
    react插件包
    react 组件列表
    css小demo
    react的项目坑
    配置react-sass
    node-sass下载失败 关于webpack
    react render
  • 原文地址:https://www.cnblogs.com/zlrrrr/p/9364020.html
Copyright © 2011-2022 走看看