hdu 2054 A == B ?
C语言题库
共 1178字,需浏览 3分钟
·
2021-07-17 21:50
A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 170516 Accepted Submission(s): 28277
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
代码:
/* HDU2054 A == B ? */
#include <stdio.h>
#include <string.h>
#define MAXN 100000
char s[MAXN], t[MAXN];
void mystrchange(char s[])
{
if(strstr(s, ".")) {
int end = strlen(s) - 1;
while(s[end] == '0')
end--;
if(s[end] == '.')
s[end] = '\0';
else
s[end+1] = '\0';
}
}
int main(void)
{
while(scanf("%s%s", s, t) != EOF) {
mystrchange(s);
mystrchange(t);
if(strcmp(s, t))
printf("NO\n");
else
printf("YES\n");
}
return 0;
}
评论