A == B ?(杭州电2054)

A == B ?

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 64239    Accepted Submission(s): 10060


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
/*第一次做总是将题目理解的过于简单。看过讨论区后
才知道要考虑非常多种情况,对于这道题的hdoj仅仅须要去掉
小数点后无意义的0就能够AC,而不须要考虑整数部分无意义
的0。不知道为啥。 
*/
#include<stdio.h>
#include<string.h>
char a[40000],b[40000];
void pop(char *s)   //去掉字符串小数部分没有意义的0。 
{
	int i,len=strlen(s)-1;
	for(i=len;i>=0;i--)
	{
		if(s[i]=='0')
		   len--;
		else
		   break;
	}
	if(s[i]=='.')//假设像9.00这种数。小数点则也须要去掉。 
	len--;
	s[len+1]='';
}
int main()
{
	int i;
	while(scanf("%s %s",a,b)!=EOF)
	{
		for(i=0;i<strlen(a);i++)
		{
			if(a[i]=='.')
			pop(a);
		}
		for(i=0;i<strlen(b);i++)
		{
			if(b[i]=='.')
			pop(b);
		}
		if(strcmp(a,b))
		printf("NO
");
		else
		printf("YES
");
	} 
	return 0;
}

版权声明:本文博主原创文章,博客,未经同意不得转载。

原文地址:https://www.cnblogs.com/bhlsheji/p/4908302.html