A == B ?
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
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#define INF 50000
char a[INF],b[INF],c[INF],d[INF];
void qudian(char *a)
{
int length,i;
length=strlen(a)-1;
for(i=strlen(a)-1;i>=0;i--)
{
if(a[i]=='0')
length--;
else
break;
}
if(a[length]=='.')
length--;
a[length+1]='\0';
// return a;
}
char quling(char *a,char *c)
{
int j,len;
//char c[INF];
len=strlen(a)-1;
j=0;
if(a[j]=='0')
{
while(a[j]=='0')
{
j++;
}
int k=j;
while(j<=len)
{
a[j-k]=a[j];
j++;
}
return *a;
}
else
return *a;
//memset(a,0,sizeof(a));
//for(i=0;i<(int)strlen(c);i++)
// a[i]=c[i];
}
int main()
{
int i,j,len1,len2,flag;
while(scanf("%s%s",a,b)!=EOF)
{
flag=0;
len1=strlen(a);
for(i=0;i<len1;i++)
{
if(a[i]=='.')
qudian(a);
}
len2=strlen(b);
for(i=0;i<len2;i++)
if(b[i]=='.')
qudian(b);
*a=quling(a,c);
*b=quling(b,d);
if(strcmp(a,b))
printf("NO\n");
else
printf("YES\n");
memset(a,0,sizeof(a));
memset(b,0,sizeof(b));
memset(c,0,sizeof(c));
memset(d,0,sizeof(d));
}
return 0;
}
posted on 2013-01-16 22:06
天YU地___PS,代码人生 阅读(507)
评论(1) 编辑 收藏