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
2 2
3 3
4 3
Sample Output
NO
YES
YES
NO
YES
YES
NO
#include <iostream>//2054 A==B
#include <string>
using namespace std;
void change(string &str)
{
if( strchr(str.c_str() , '.' ) )
{
int last=str.length();
while(str[--last]=='0') str.erase(last,1) ; //删除后置0
if( str[last]=='.' ) str.erase(last,1) ; //若全为0,删除小数点
}
while(str[0]=='0')//前置0的处理
{
if( str.length()!=1 ) str.erase(0,1);//若全为0,则保存一个0
else return;
}
}
int main()
{
string a,b;
while(cin>>a>>b)
{
change(a);
change(b);
if(a.compare(b)==0) cout<<"YES"<<endl;
else cout<<"NO"<<endl;
}
}