A == B ?
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 64960 Accepted Submission(s): 10164
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 <iostream> #include <cstdio> #include <cstring> using namespace std; #define LEN 100000 int main() { char a[LEN]; char b[LEN]; int lena, lenb, len, i; while(cin >> a >> b) { lena = 0; lenb = 0; len = strlen(a); len--; for(i = 0; i <= len; i++) { if(a[i] == '.') { lena = i; break; } } while(a[len] == '0' && len > lena && lena != 0) { a[len] = '\0'; len--; } if(a[len] == '.') { a[len] = '\0'; } len = strlen(b); len--; for(i = 0; i <= len; i++) { if(b[i] == '.') { lenb = i; break; } } while(b[len] == '0' && len > lenb && lenb != 0) { b[len] = '\0'; len--; } if(b[len] == '.') { b[len] = '\0'; } if(strcmp(a, b) == 0) { cout << "YES" << endl; } else { cout << "NO" << endl; } } return 0; }