hdu-2054 A == B ?

Problem Description
Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".
 

Input
这道题目,刚开始做的时候我只考虑开头的时候有+这种情况,想错了,这道题目主要是考的是小数点跟小数点后边的零。。。
strchr函数:
函数名称:           strchr
函数原型:           char*   strchr(char*   str,char   ch);
函数功能:           找出str指向的字符串中第一次出现字符ch的位置
函数返回:           返回指向该位置的指针,如找不到,则返回空指针
参数说明:           str-待搜索的字符串,ch-查找的字符
代码:#include<stdio.h>
#include<string.h>
char str1[1000000];
char str2[1000000];
void ch(char *s){
	int num;
	num=strlen(s);
	if(strchr(s,'.')!=NULL){
		while(s[--num]=='0') ;
		if(s[num]=='.')  num--;
		s[num+1]='\0';
	}
}
int main(){
	while(~scanf("%s%s",str1,str2)){
		ch(str1);
		ch(str2);
		if(strcmp(str1,str2)==0)
		   printf("YES\n");
		else
		   printf("NO\n");
	}
	return 0;
}

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
posted @ 2014-11-08 22:29  wojiaohuangyu  阅读(17)  评论(0)    收藏  举报