HDU 2054

来源:互联网 发布:张逗张花 知乎 编辑:程序博客网 时间:2024/06/10 14:39

A == B ?

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


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 22 23 34 3
 

Sample Output
NOYESYESNO
 

Author
8600 && xhd
 

Source
校庆杯Warm Up

题目大意:A==B?

题目思路:不知道这个题是让干什么的,翻了discuss后发现要处理大数的比较,多种类型数据的比较,及小数2.020  2.02之类的比较。用C++ string类即可

题目代码:
#include<iostream>
#include<string>
using namespace std;
string a, b;
//char a[100005];
//char b[100005];
//void deal(char[] &t)
void deal(string &t)
{
for (int i = 0; i < t.size(); i++)
{
if (t[i] == '.')
{
auto it = t.end() - 1;
for (it; *it == '0'; it--)
{
if (*it == '0')t.erase(it);
}
if (*it == '.')t.erase(it);
/*int j;
for (j = t.size() - 1; t[j]=='0'; j--)
{
if (t[j] == '0')
t[j] = '\0';
}
if (t[j] == '.')t[j] = '\0';*/
break;
}
}
}
int main()
{
while (cin >> a >> b)
//while(~scanf("%s%s",a,b))
{
deal(a);
//cout << a << endl;
deal(b);
// cout << b << endl;
if (a==b)
printf("YES\n");
else
printf("NO\n");
}
}






#include<iostream>
#include<string>
using namespace std;
char a[100005];
char b[100005];
void deal(char t[])
{
for (int i = 0; i < strlen(t); i++)
{
if (t[i] == '.')
{
int j;
for (j = strlen(t) - 1; t[j]=='0'; j--)
{
if (t[j] == '0')
t[j] = '\0';
}
if (t[j] == '.')t[j] = '\0';
break;
}
}
}
int main()
{
while(~scanf("%s%s",a,b))
{
deal(a);
deal(b);
if (!strcmp(a,b))
printf("YES\n");
else
printf("NO\n");
}
}
 
原创粉丝点击