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 }
     
  • 相关阅读:
    8.1.3 CSS3选择器 —— 伪类
    8.1.2 CSS3选择器 —— 结构性伪类
    VI打开和编辑多个文件的命令
    vi全局替换方法
    更改Ubuntu 12.04默认的shel
    如何区分直连串口线和交叉串口线?
    [转]OpenWrt的dl下载地址
    关闭 ubuntu System program problem detected
    linuxC学习
    aa
  • 原文地址:https://www.cnblogs.com/tenjl-exv/p/8051721.html
Copyright © 2011-2022 走看看