题目链接:点击打开链接
A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 62097 Accepted Submission(s): 9737
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<stdio.h>
#include<string.h>
char a[100000],b[100000];//数组要适当开大点,否则会过不了
bool f(char a[],int len) //判断输入的数据是否含有小数点
{
int i;
for(i=0;i<len;++i)
if(a[i]=='.')
return true;
return false;
}
void g(char a[],int len1) //功能:若数据含有小数点,去除末尾的无效0,若不含小数点,在末尾补加以为"."
{
if(f(a,len1))
{
for(int k=len1-1;k>=0;--k)
{
if(a[k]!='0')
break;
else
a[k]='\0';
}
}
else
{
a[len1]='.';
}
}
int main()
{
while(~scanf("%s%s",a,b))
{
int i,j,len1=strlen(a),len2=strlen(b);
for(i=0;;++i)
if(a[i]!='0')
break;
for(j=0;j>0;++j)
if(b[j]!='0')
break;
g(a,len1);
g(b,len2);
if(strcmp(a+i,b+j)==0)
printf("YES\n");
else
printf("NO\n");
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
}
return 0;
}