http://acm.hdu.edu.cn/showproblem.php?pid=2054
Problem Description
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
题解:不需要考虑前置零 把小数点后面多余的 0 去掉再进行比较就可以
代码:
#include <bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
char a[maxn],b[maxn];
void rep(char s[]) {
int len=strlen(s);
int flag=0;
for(int i=0;i<len;i++) {
if(s[i]=='.') {
flag=1;
break;
}
}
if(flag) {
for(int i=len-1;i>=0;i--) {
if(s[i]=='0') s[i]='\0';
else break;
len--;
}
if(s[len-1]=='.') s[len-1]='\0';
}
}
int main() {
while(~scanf("%s%s",a,b)) {
rep(a);
rep(b);
if(strcmp(a,b))
printf("NO\n");
else
printf("YES\n");
}
return 0;
}