5C - 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

// too young
 1 #include<stdio.h>
 2 int main()
 3 {
 4     int a, b;
 5     while(scanf("%d %d", &a, &b)!=EOF)
 6     {
 7         if(a==b) printf("YES\n");
 8         else printf("NO\n");
 9     }
10     return 0;
11 }
Output Limit Exceeded
// still don't know why
 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 int main()
 4 {
 5     double a,b;
 6     char num1[1000000], num2[1000000];
 7     while(scanf("%s %s", num1, num2)!=EOF)
 8     {
 9         a=atof(num1); b=atof(num2);
10         if(a==b) printf("YES\n");
11         else printf("NO\n");
12     }
13     return 0;
14 }
WA
// 小数点后无意义的零要删去
 1 #include<stdio.h>
 2 #include<string.h>
 3 char a[1000000], b[1000000];
 4 void process(char *num)
 5 {
 6     int len=strlen(num);
 7     if(strstr(num,".")!=NULL)
 8     {
 9         while(num[--len]=='0');
10         if(num[len]=='.')
11             num[len]='\0';
12     }
13 }
14 int main()
15 {
16     while(scanf(" %s %s", a, b)!=EOF)
17     {
18         process(a); process(b);
19         if(strcmp(a,b)) printf("NO\n");
20         else printf("YES\n");
21     }
22     return 0;
23 }
WA*2
// 
 1 #include<stdio.h>
 2 #include<string.h>
 3 char a[1000000], b[1000000];
 4 void process(char *num)
 5 {
 6     int len=strlen(num);
 7     if(strstr(num,".")!=NULL)
 8     {
 9         while(num[--len]=='0');
10         if(num[len]=='.')
11             len--;
12         num[++len]='\0';
13     }
14 }
15 int main()
16 {
17     while(scanf(" %s %s", a, b)!=EOF)
18     {
19         process(a); process(b);
20         if(strcmp(a,b)) printf("NO\n");
21         else printf("YES\n");
22     }
23     return 0;
24 }
AC
// 判断两数是否相等还可用strcmp
// char *strstr(char *str1, char *str2); 寻找str2在str1中第一次出现的位置,返回位置指针

猜你喜欢

转载自www.cnblogs.com/goldenretriever/p/10355777.html