HDU-2054 A == B ?

A == B ?

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


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
#include<iostream>
#include<string.h>
using namespace std;
char a[20000],b[20000];
void change(char* a)
{
	int i,n=strlen(a);
	if(strstr(a,"."))
	{
		for(i=n-1;a[i]=='0';i--)
		{
			a[i]='\0';
			n--;
		}
	}
	if(a[n-1]=='.')
	a[n-1]='\0';
}
int main()
{
	while(cin>>a>>b)
	{
		change(a);
		change(b);
		if(strcmp(a,b))
		cout<<"NO"<<endl;
		else cout<<"YES"<<endl;	
	}	
	return 0;
}



猜你喜欢

转载自blog.csdn.net/qq_41333844/article/details/80343042