您的位置:首页 > 其它

HDU 2054

2017-09-16 12:57 295 查看

A == B ?

Time Limit: 1000/1000 MS (Java/Others)    Memory Limit: 32768/32768 K (Java/Others)

Total Submission(s): 109296    Accepted Submission(s): 17488


[align=left]Problem Description[/align]
Give you two numbers A and B, if A is equal to B, you should print "YES", or print "NO".
 

[align=left]Input[/align]
each test case contains two numbers A and B.

 

[align=left]Output[/align]
for each case, if A is equal to B, you should print "YES", or print "NO".
 

[align=left]Sample Input[/align]

1 2
2 2
3 3
4 3

 

[align=left]Sample Output[/align]

NO
YES
YES
NO

 

[align=left]Author[/align]
8600 && xhd
 

[align=left]Source[/align]
校庆杯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");
}

}

 
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: