http://acm.hdu.edu.cn/showproblem.php?pid=2054
View Code
1 #include<stdio.h> 2 #include<string.h> 3 4 int isdec( const char *p ) 5 { 6 int i; 7 int len=strlen(p); 8 for( i=0 ; i<len ; i++ ) 9 { 10 if( *p == '.' ) 11 return 1; 12 p++; 13 } 14 return 0; 15 } 16 17 void change( char *p ) 18 { 19 int len = strlen(p); 20 char *last = p+len-1; 21 while( *last == '0' ) 22 *last-- = '\0'; 23 if( *last == '.' ) //特别注意这个小数点 24 *last = '\0'; 25 printf("%s\n",p); 26 } 27 28 int main( ) 29 { 30 char a[200000]; 31 char b[200000]; 32 char *x; 33 char *y; 34 while( scanf("%s %s",a,b) != EOF ) 35 { 36 x = a; 37 y = b; 38 while( *x == '0' ) 39 x++; 40 while( *y == '0' ) 41 y++; 42 if( isdec(a) ) 43 change(a); 44 if( isdec(b) ) 45 change(b); 46 puts( strcmp(x,y)?"NO":"YES" ); 47 } 48 return 0; 49 }