hdu2054

A == B ?

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 57842    Accepted Submission(s): 8895


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,把小数点后的多余0消掉
但这个考的是大数,所以是long long都不好用,只好用数组,就这些 看代码
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<string>
#include<algorithm>
#include<cmath>
using namespace std;
void tras( char a[])
{
    int len ,i;
    len=strlen(a);
    if(strstr(a,"."))//到小数点结束
    {
        for( i=len-1;a[i]=='0';i--)
        {
            a[i]='\0';
            len--;
        }
    }

    if(a[len-1]=='.')
    {
        a[len-1]='\0';
    }
}
int main()
{
   char a[100000],b[100000];//需要这么大,刚开始我设小了一直不过!
    while(cin>>a>>b)
    {
        tras(a);
        tras(b);
        if(strcmp(a,b)==0)
            cout<<"YES"<<endl;
        else
            cout<<"NO"<<endl;
    }
    return 0;
}


  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值