一道关于A==B?的题目。。AB可能非常大,可能出现0.100这种数字,为什么还是wrong answer 求指教TT
Problem DescriptionGive 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<string.h>
int main()
{
char str1[100],str2[100];
while(scanf("%s%s",str1,str2)!=EOF)
{
int len1,len2,i,j;
len1=strlen(str1);
len2=strlen(str2);
for(i=0;i<len1;i++)
{
if(str1[i]=='.')
for(j=len1-1;j>=0;j--)
{
if(str1[j]=='0')str1[j]='\0';
else break;
}
}
if(str1[strlen(str1)-1]=='.')str1[strlen(str1)-1]='\0';
for(i=0;i<len2;i++)
{
if(str2[i]=='.')
for(j=len2-1;j>=0;j--)
{
if(str2[j]=='0')str2[j]='\0';
else break;
}
}
if(str2[strlen(str2)-1]=='.')str2[strlen(str2)-1]='\0';
if(strcmp(str1,str2)==0)printf("YES");
else printf("NO");
}
}