Hduoj2054【水题】

来源:互联网 发布:电工仿真软件 编辑:程序博客网 时间:2024/05/22 00:44
/*A == B ?Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 64017    Accepted Submission(s): 10012Problem DescriptionGive you two numbers A and B, if A is equal to B, you should print "YES", or print "NO". Inputeach test case contains two numbers A and B. Outputfor each case, if A is equal to B, you should print "YES", or print "NO". Sample Input1 22 23 34 3 Sample OutputNOYESYESNO Author8600 && xhd Source校庆杯Warm Up */ #include<stdio.h>#include<string.h>char a[10000000], b[10000000];int find(char * s){int i = strlen(s);while(s[i] != '.' && i)i--;if(i==0)return strlen(s);else return i; }int main(){while(scanf("%s%s", a, b) != EOF){int m , n, i, j, k, l1,l2, p1, p2;m = strlen(a);n = strlen(b);p1 = find(a);for(i = 0; i < p1; i++)if(a[i] != '0'){l1 = i;break;}if(i == p1)// 数点前全部为0 或者 字符串全部为0 l1 = p1-1; //从 前一位开始比较 p2 = find(b);for(j = 0; j < p2; j++)if(b[j] != '0'){l2 = j;break;}if(j == p2)l2 = p2-1; for(i = m-1; i >= p1; i --)//去尾0 if(a[i] =='0' || a[i] == '.')a[i] = '\0';else break;for( j = n-1; j >= p2; j --)if(b[j] == '0' || b[j] == '.')b[j] = '\0';elsebreak;if(strcmp(a+l1, b+l2) == 0)printf("YES\n");elseprintf("NO\n"); }return 0;} 

0 0
原创粉丝点击