ACM 1081 A==B?给定两个数A和B(长度不超过100),如果它们相等则输出"YES",否则输出"NO".输入每
1个回答

这个题目中的数的长度最大是100,我们无法用普通的数据类型来存储,只能通过字符串存储来做比较.

下面是一份AC的代码,你参考下.

#include

#include

void A(char *s)

{

int len = strlen(s);

char *p = s + len - 1;

if (strchr(s, '.'))

while (*p == '0') *p-- = 0;

if (*p == '.') *p = 0;

}

int main(void)

{

char *pa, *pb;

char a[100024], b[100024];

while (scanf("%s%s", a, b) != EOF)

{

pa = a; pb = b;

while (*pa == '0') pa++;

while (*pb == '0') pb++;

A(pa); A(pb);

puts(strcmp(pa, pb) ? "NO" : "YES");

}

return 0;

}