HDU 2054 A==B?

来源:互联网 发布:广州多益网络 徐波 编辑:程序博客网 时间:2024/06/06 03:59
A == B ?Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 90991    Accepted Submission(s): 14492Problem 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 3Sample OutputNOYESYESNOAuthor8600 && xhdSource校庆杯Warm Up技巧很独特,独辟蹊径~
#include<cstdio>#include<cstring>using namespace std;#define MAX 100100char A[MAX],B[MAX];/*后面有多余的0全部变成字符数组结尾标志'\0'如果出现2.000 和 2这样的情况 把'.'变成'\0' */ void Clean(char str[]){    int len=strlen(str),i;    //注意strchr()函数返回的是一个指针     if(strstr(str,".")!=NULL){        for(i=len-1;str[i]=='0';i--)            str[i]='\0';        if(str[i]=='.')            str[i]='\0';    }}int main(){    while(scanf("%s%s",A,B)!=EOF){        Clean(A);        Clean(B);        //strcmp()完全相等时返回0         if(strcmp(A,B)!=0)            printf("NO\n");        else            printf("YES\n");    }}
0 0
原创粉丝点击