#include <stdio.h> #include <string.h> #define MAXN 1000001 char *fun(char *); char str1[MAXN],str2[MAXN]; int main() { int len; int i; while(~fscanf(stdin,"%s%s",str1,str2)) { if(strcmp(fun(str1),fun(str2)) == 0) printf("YES\n"); else printf("NO\n"); } return 0; } char* fun(char *s) { int sign; int i,j; int len; /*预处理转换成统一形式,以便边下一步处理*/ len = strlen(s); if(strchr(s,'.') == NULL) { s[len] = '.'; s[++len] = '\0'; } /*前导部分*/ if(s[0] == '-') { sign = 1; s++; } else sign = 0; while(*s == '0') s++; /*小数点有效前部分,保存*/ i = 0; while(s[i] != '.') i++; /*保存小数点后有效部分,删掉无效后缀*/ len = strlen(s); for(j = len-1; s[j] != '.' && s[j] == '0'; j--) ; //*s[i] == '.' || isdigit(s[i]) if(sign && *s != '.') s[++j] = '-'; s[++j] = '\0'; return s; } |