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
Sample Output
NO
YES
YES
NO
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
int main()
{
char a[100024],b[100024],c[100024],d[100024];//万恶的数组,刚开始因为开小了,结果一直wa,都找不到原因
memset(c,0,sizeof(c));
memset(d,0,sizeof(d));
while(scanf("%s%s",a,b)!=EOF)
{
int j=0;
while(a[j]=='0')
{
j++;
}
int k=j;
while(a[j])
{
c[j-k]=a[j];
j++;
}
j=0;//对a数组删除前面输入的零,e.g00001==1
while(b[j]=='0')
{
j++;
}
k=j;
while(b[j])
{
d[j-k]=b[j];
j++;
}//对b数组删除前面输入的零
j=0;
if(strchr(c,'.'))//字符串判断函数,如果c字符串中含有'.'则返回'.'的位置指针,否则返回NULL
{
while(c[j])
{
j++;
}
j--;
while(c[j]=='0')
{
c[j]='\0';
j--;
}//删除小数点后面的零,e.g 123.000=123.00000000
if(c[j]=='.')
c[j]='\0';//删除小数点,e.g 123.0000=123
}
j=0;
if(strchr(d,'.'))
{
while(d[j])
{
j++;
}
j--;
while(d[j]=='0')
{
d[j]='\0';
j--;
}
if(d[j]=='.')
d[j]='\0';
}//类似以上处理
if(strlen(c)!=strlen(d))
printf("NO\n");//判断长度是否相等
else//比较
{
int i=0,t=0;
while(c[i])
{
if(c[i]!=d[i])
{
t++;
break;
}
i++;
}
if(t==0)
{
printf("YES\n");
}
else
{
printf("NO\n");
}
}
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
memset(d,0,sizeof(d));
}
//system("pause");
return 0;
}