您的位置:首页 > 其它

HDU 2054

2014-08-03 13:54 246 查看
HDU 2054 A==B?

#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<queue>
#define N 1006
using namespace std;

void Change(string &str)
{
if(strchr(str.c_str(),'.'))//判断字符串str中是否有'.'
{
int lenstr = str.length();
while(str[--lenstr] == '0') str.erase(lenstr,1);//将后面的0删除
if(str[lenstr] == '.') str.erase(lenstr,1);//如果最后一个字符是'.',删除
}
while(str[0] == '0')//将字符串中前面的0删除
{
if(str.length() != 1) str.erase(0,1);//如果全部都是0,保留一个0
else return ;
}
}

int main()
{
#ifdef ONLINE_JUDGE
#else
//freopen("E:\\我的程序\\in.txt","r",stdin);
//freopen("E:\\我的程序\\out.txt","w",stdout);
#endif
string a, b;
while(cin >> a >> b)
{
Change(a);
Change(b);
if(a.compare(b) == 0) cout << "YES" << endl;//判断字符串a,b是否相等
else cout << "NO" << endl;
}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: