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

    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
     
    分析:
    此题在于比较以下集中情况的数据:
    ①数值超过数据类型范围,比如超过64位的数据
    ②数值有前导零(此题测试不用考虑前导零)
    ③数值有小数点
    ④数值小数点后有后导零
    注意点:
    数据位数一定要开大,经测试,最大一个测试数据在12000到12050之间
    所以最小也得12050以上
     1 #include<iostream>
     2 #include<cstring>
     3 using namespace std;
     4 
     5 void gg(char *s)
     6 {
     7     int len=strlen(s); 
     8     if(strchr(s,'.'))
     9     {
    10         for(len-=1;s[len]=='0';len--);
    11         if(s[len]=='.')
    12             s[len]='';
    13         else
    14             s[len+1]='';
    15     }
    16 }
    17 int main()
    18 {
    19     char m[20000],n[20000];
    20     memset(m,0,sizeof(m));
    21     memset(n,0,sizeof(n));
    22     while(cin>>m>>n)
    23     {
    24         gg(m);
    25         gg(n);
    26         if(strcmp(m,n)==0)
    27         cout<<"YES"<<endl;
    28         else
    29         cout<<"NO"<<endl;
    30     }
    31     return 0;
    32 }
     
  • 相关阅读:
    个人作业-Alpha项目测试
    第三次作业-结对编程
    第二次作业
    第一次阅读作业
    canal同步mysql数据至es5.5.0
    工作一周年小结
    Java集合操作 遍历list并转map
    网易秋招校招编程题
    堆外内存总结
    网易秋招内推编程题题解
  • 原文地址:https://www.cnblogs.com/tenjl-exv/p/8051721.html
Copyright © 2011-2022 走看看