首先我处理了前导的0;

        while( *p1 == '0' )
               p1++;
           while( *p2 == '0' )
               p2++;

用了指针移动指向来实现的。

然后处理了“.”号, 因为在小数中,一个小数点,后面什么也没有,可以。所以我讲小数点置为空。

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

而且处理了后导0, 就使后面所以的0 都置为空,就相当于没有。

最后比较就可以了~~

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
 
 
 
 1 #include<stdio.h>
2 #include<stdlib.h>
3 #include<string.h>
4 char a[100020], b[100020];
5 void deal( char *p )
6 {
7 int len = strlen( p );
8 char *p1 = p + len - 1;
9 if( strchr( p, '.' ) )
10 while( *p1 == '0' ) *p1-- = 0;
11 if( *p1 == '.' ) *p1 = 0;
12
13 }
14
15 int main( void )
16 {
17
18 char *p1, *p2;
19 while( scanf( "%s%s", a, b ) == 2 )
20 {
21 p1 = a;
22 p2 = b;
23 while( *p1 == '0' )
24 p1++;
25 while( *p2 == '0' )
26 p2++;
27 deal ( p1 );
28 deal ( p2 );
29 puts( strcmp( p1, p2 ) ? "NO" : "YES" );
30 }
31 return 0;
32 }
posted on 2011-12-09 12:01  狸の舞  阅读(620)  评论(0编辑  收藏  举报