当前位置: 代码迷 >> 综合 >> HDU A - A == B ? HDU - 2054
  详细解决方案

HDU A - A == B ? HDU - 2054

热度:44   发布时间:2024-01-09 16:08:37.0

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

经验教训:数组太小或太大都会WA或TLE或RE
代码:(所有的双等号都要删去其中空格)
#include <stdio.h>
#include <string.h>
char *change(char *a)
{
int len = strlen(a);
if(strchr(a,’.’) != NULL)
{
while(a[–len]= =‘0’);
if(a[len]==’.’)
len–;
a[len+1]=’\0’;
}
return a;
}
int main()
{
char a[50000], b[50000];
while(~scanf("%s %s", a, b))
{
if(!strcmp(change(a),change(b)))
printf(“YES\n”);
else
printf(“NO\n”);
}
return 0;
}