杭电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

简单的大数,此题有如下几个要点:
1、数前有零;
这一步就用for(int i=0;a[i]==’0’&&i
a[i]=’a’;
将需要删除的数赋值为 a。
2,、小数点后有零;
首先判断是否小数点,若有小数点则对最后一位去零处理,
for(int i=strlen(a);(a[i]==’.’||a[i]==’0’)&&i>0;i++)
a[i]=’a’;
3、将不为a的数值赋给另一个字符串c[j++];d[j++];

4、strcmp比较c和d

#include<stdio.h>
#include<string.h>
int main()
{
    char a[100005],b[100005];
    while(scanf("%s%s",a,b)!=EOF)
    {
        char c[100005]={0},d[100005]={0};
        int mark_a=0,mark_b=0;
        for(int i=0;i<strlen(a)-1&&a[i]=='0';i++)
            a[i]='a';
        for(int i=0;i<strlen(b)-1&&b[i]=='0';i++)
            b[i]='a';
        for(int i=0;i<strlen(a)||i<strlen(b);i++)
        {
            if(a[i]=='.')
                mark_a=i;
            if(b[i]=='.')
                mark_b=i;
        }
        for(int i=strlen(a)-1;mark_a&&(a[i]=='0'||a[i]=='.')&&i>=mark_a;i--)
            a[i]='a';
        for(int i=strlen(b)-1;mark_b&&(b[i]=='0'||b[i]=='.')&&i>=mark_b;i--)
            b[i]='a';
        for(int i=0,j=0;i<strlen(a);i++)
            if(a[i]!='a')
                c[j++]=a[i];
        for(int i=0,j=0;i<strlen(b);i++)
            if(b[i]!='a')
                d[j++]=b[i];
        if(strcmp(c,d)==0)
            printf("YES\n");
        else printf("NO\n");
    }
}
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值