Y - A == B ?
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
题意很简单,给你两个数字,问他们是否相等
思路:肯定是非常大的数,所以用字符串存储。然后对字符串进行处理,处理方法:
①删掉数字前无意义的0
②删掉小数点后数字最后的0
比较时用字符串比较函数即可。
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
void change(char s[]);
int main()
{
char a[50000],b[50000];
while(scanf("%s%s",a,b)!=EOF)
{
change(a);
change(b);
if(strcmp(a,b))
{
printf("NO\n");
}
else
{
printf("YES\n");
}
}
return 0;
}
void change(char s[])
{
int l,i=0,flag=0;
l=strlen(s);
if(strchr(s,'.')!=NULL)
{
while(s[l-1]=='0')
{
s[l-1]='\0';
l--;
}
if(s[l-1]=='.')
{
s[l-1]='\0';
}
}
char *p=s;
while(*p=='0') p++;
strcpy(s,p);
}