題目大意:給兩個數A和B,如果A和B相等,就輸出YES,否則輸出NO
該題似乎只用多考慮一種情況,例如1.00000和1
/*
*
*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
*
*
*Author
*8600 && xhd
*
*
*Source
*校慶杯Warm Up
*
*
*Recommend
*linle
*
*/
#include<iostream>
#include<string>
using namespace std;
int i;
void split(string &s) {
if (s.find('.') == string::npos) return;
for (i = 0; i < s.size(); ++i) {
if (s.at(s.size() - 1 - i) != '0') {
s.erase(s.end() - i, s.end());
break;
}
}
if (s.at(s.size() - 1) == '.') {
s.erase(s.end() - 1, s.end());
}
}
int main() {
string a, b;
while (cin >> a >> b) {
split(a);
split(b);
if (a == b)
cout << "YES" << endl;
else
cout << "NO" << endl;
}
system("pause");
return 0;
}