0
点赞
收藏
分享

微信扫一扫

HDU 2054 A == B ? 字符串处理


A == B ?


Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)
Total Submission(s): 63662    Accepted Submission(s): 9961

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


/*
HDU 2054 字符串处理
刚开始没看懂 看了下别人的 这题不好 啥都没说明
有人说有+ -号 但是好像没有
去除前置的的0和小数点后不为零数字后面的0

0000.1 0.1000000
.1 0.1
000.000 0
123456789123456789 123456789123456789
000001000. 1000
*/
#include<iostream>
#include<stdio.h>
#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 num1,num2;
while(cin>>num1>>num2)
{
change(num1);
change(num2);
if(num1.compare(num2)==0)
cout<<"YES"<<endl;
else
cout<<"NO"<<endl;

}
return 0;
}




举报

相关推荐

0 条评论