HDOJ2054:A==B? 字符串处理、看似水题

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;
char a[100000], b[100000];
bool is(char *p)
{
	for (; *p != ' '; p++)
	if (*p == '.')return true;
	return false;
}

void det(char *p)
{
	for (; *p != ' '; p++);
	p--;
	for (; *p == '0'; p--)
		*p = ' ';
	if (*p == '.')*p = ' ';
}

int main()
{
	while (cin >> a >> b)
	{
		if (is(a))det(a);
		if (is(b))det(b);
		if (strcmp(a, b) == 0)cout 

					

发表评论

您的电子邮箱地址不会被公开。