hdu2054 A == B ?(高精度比较)

来源:互联网 发布:李连杰眼睛 知乎 编辑:程序博客网 时间:2024/05/22 02:01

A == B ?

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


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 22 23 34 3
 

Sample Output
NOYESYESNO
 

#include<stdio.h>#include<string.h>char a[100004],b[100004];int dot(char x[]){    int len=strlen(x),i;    for(i=0; i<len; i++)    {        if(x[i]=='.')        {            int j=len-1;            while(x[j]=='0')            {//去掉末尾的零                len--;                j--;            }            break;        }    }    if(x[len-1]=='.') len--;//去掉整数的小数点    return len;}int main(){    while(scanf("%s%s",a,b)!=EOF)    {        int la=dot(a),lb=dot(b);        if(la!=lb)        {            printf("NO\n");            continue;        }        bool ok=1;        for(int i=0; i<la; i++)            if(a[i]!=b[i])            {                ok=0;                break;            }        if(ok) printf("YES\n");        else printf("NO\n");    }    return 0;}


0 1
原创粉丝点击