Hdu2054:A==B?大数高精度算法

来源:互联网 发布:南京外国语学校知乎 编辑:程序博客网 时间:2024/06/05 17:38

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

#include<stdio.h>#include<stdlib.h>#include<string.h>void test(char a[],int end){      //去掉小数点后的0    if(strstr(a,".")){            //判断数组带不带小数点        while(a[end-1]=='0'){            a[end-1]='\0';            end--;        }        if(a[end-1]=='.'){            a[end-1]='\0';        }    }}int main(){    char a[100000],b[100000];    //把数组设的足够大    while(~scanf("%s%s",a,b)){        test(a,strlen(a));        test(b,strlen(b));        if(!strcmp(a,b))            printf("YES\n");        else            printf("NO\n");    }    return 0;}
1 0
原创粉丝点击