永发信息网

HDU 2054 A == B ?A但是看不太明白,麻烦高手解析

答案:2  悬赏:0  手机版
解决时间 2021-03-22 22:47
  • 提问者网友:放下
  • 2021-03-22 12:48
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 38421 Accepted Submission(s): 5912

#include
#include
#include
char str1[100000], str2[100000];
void deal(char *str)
{
int i, j, len;
char *p = str;
while( *p == '0')
p++;
strcpy(str, p);
if(strchr(str, '.'))
{
len = strlen(str);
p = len + str - 1;
while( *p == '0')
*(p--) = 0;
if (*p == '.')
*p = 0;
}
}
int main( )
{
while(scanf("%s%s", str1,str2)!= EOF)
{
deal(str1);
deal(str2);
if (strcmp(str1, str2) == 0)
puts("YES");
else
puts("NO");
}
return 0;
}

Give 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 2
2 2
3 3
4 3
Sample OutputNO
YES
YES
NO
最佳答案
  • 五星知识达人网友:野慌
  • 2021-03-22 12:55
原理是去掉末尾多余的0和小数点(如果能去掉的话)还有多余的前导0
最后比较2字串
全部回答
  • 1楼网友:雾月
  • 2021-03-22 13:15
你写的是jar的吖
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯