一个字符串处理问题,需要注意的是小数点问题,如果小数点后面有0,则需要将小数点后面的0,去掉,才能相互比较。
strstr( s , "." )
即可查到字符串s中是否有小数点,如果查到,返回小数点在字符串中的位置,如果不存在,则返回NULL
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std ;
char s1[100000] , s2[100000] ;
void exchange( char *s ) {
int i , len ;
len = strlen(s) ;
if(strstr(s,".")) {
for(int i = len - 1 ; s[i] == '0' ; i--) {
s[i] = '\0';
len-- ;
}
}
if(s[len-1]=='.')
s[len-1]='\0';
}
int main() {
while(scanf("%s%s",s1,s2) != EOF) {
exchange(s1) ;
exchange(s2) ;
if(strcmp(s1,s2))
puts("NO") ;
else
puts("YES") ;
}
return 0 ;
}