A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 56411 Accepted Submission(s): 8680
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[100004],b[100004];
int dot(char x[])
{
int len=strlen(x),i;
for(i=0; i<len; i++)
{
if(x[i]=='.')
{
int j=len-1;
while(x[j]=='0')
{//去掉末尾的零
len--;
j--;
}
break;
}
}
if(x[len-1]=='.') len--;//去掉整数的小数点
return len;
}
int main()
{
while(scanf("%s%s",a,b)!=EOF)
{
int la=dot(a),lb=dot(b);
if(la!=lb)
{
printf("NO\n");
continue;
}
bool ok=1;
for(int i=0; i<la; i++)
if(a[i]!=b[i])
{
ok=0;
break;
}
if(ok) printf("YES\n");
else printf("NO\n");
}
return 0;
}