给你两个很大的数,你能不能判断出他们两个数的大小呢?
比如123456789123456789要大于-123456
111111111111111111111111111 88888888888888888888 -1111111111111111111111111 22222222 0 0
a>b a<b
//该题比较简单,主要一直AC不过是因为未看清题意若两个数相等应该输出a==b而不是a=b
#include<iostream>
#include<stdio.h>
#include<string.h>
using namespace std;
char a[1002],b[1002];
int main()
{
	
	while(cin>>a>>b)
	{
		int x=strlen(a),y=strlen(b);
		if(strcmp(a,"0")==0&&strcmp(b,"0")==0)
			break;
		else
		{
		if(a[0]=='-'&&b[0]!='-')
			cout<<"a<b"<<endl;
		else if(a[0]!='-'&&b[0]=='-')
			cout<<"a>b"<<endl;
		else if(a[0]=='-'&&b[0]=='-')
		{
			if(x==y)
			{
				if(strcmp(a,b)>0)
					cout<<"a<b"<<endl;
				else if(strcmp(a,b)<0)
					cout<<"a>b"<<endl;
				else if(strcmp(a,b)==0)
					cout<<"a==b"<<endl;
			}
			else 
			{
				if(x-y>0)
					cout<<"a<b"<<endl;
				else if(x-y<0)
					cout<<"a>b"<<endl;
			}
		}
		else
		{
			if(x==y)
			{
				if(strcmp(a,b)>0)
					cout<<"a>b"<<endl;
				else if(strcmp(a,b)<0)
					cout<<"a<b"<<endl;
				else if(strcmp(a,b)==0)
					cout<<"a==b"<<endl;
			}
			else
			{ 
				if(x-y<0)
					cout<<"a<b"<<endl;
		     	else if(x-y>0)
					cout<<"a>b"<<endl;
			}
		}
		}
	}
	return 0;
}版权声明:本文为博主原创文章,未经博主允许不得转载。
原文:http://blog.csdn.net/phytn/article/details/46788281