A == B?
首先我處理了前導的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 }
轉載于:https://www.cnblogs.com/zsj576637357/archive/2011/12/09/2281800.html
總結
- 上一篇: 创建型模式(五):Singleton(单
- 下一篇: delphi 画 带箭头的线