A == B ?
#include <iostream> #include <string> using namespace std; void deal(string &s) { int len = s.length(); if(s.find('.') != string::npos) { for(int i = len - 1; s[i] == '0'; -- i) { len --; } s = s.substr(0, len); if(s[len - 1] == '.') { s = s.substr(0, len - 1); } } } int main() { string a, b; while(cin >> a >> b) { deal(a); deal(b); if(a == b) cout << "YES" << endl; else cout << "NO" << endl; } return 0; }