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
授权协议:创作共用 署名-非商业性使用 2.5 中国大陆除注明外,本站文章均为原创;转载时请保留上述链接。