**A == B ?**
Time Limit: 1000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 170631 Accepted Submission(s): 28298
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
#include
using namespace std;
void erasew(string &str)
{
for(int i=0,flag=0;i<str.length();i++)
{
if(str[i]==’.’)
{
while(str[str.length()-1] ‘0’)
str.erase(str.length()-1,1);
if(str[str.length()-1]’.’)
{
str.erase(str.length()-1,1);
flag=1;
}
}
if(flag)
break;
}
}
void eraset(string &str)
{
while((str[0]<=‘0’||str[0]>‘9’)&&str[1]!=’.’)
str.erase(0,1);
}
bool fuhao(string &str)
{
if(str[0]==’-’)
-
List item
return false;
else
return true;
}
int main()
{
string str1,str2;
while(cin>>str1>>str2)
{if(fuhao(str1)!=fuhao(str2)) cout<<"NO"<<endl; eraset(str1); erasew(str1); eraset(str2); erasew(str2); if(str1==str2) cout<<"YES"<<endl; else cout<<"NO"<<endl;
}
}
看了别人的方法理解然后写的