Description
给出两个数字串,比较这两个数字串的大小
Input
两个数字串,串长均不会超过10^6
Output
比较两个数字的大小
Sample Input
00012345
12345
Sample Output
=
Solution
水题,先去掉前置0,之后比长度,长度相同则比较字典序
Code
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
#define maxn 1111111
char a[maxn],b[maxn];
int main()
{
while(~scanf("%s%s",a,b))
{
int la=strlen(a),lb=strlen(b);
int i=0,j=0,flag;
while(i<la&&a[i]=='0')i++;
while(j<lb&&b[j]=='0')j++;
if(la-i>lb-j)flag=1;
else if(la-i<lb-j)flag=-1;
else if(la-i==lb-j)flag=strcmp(a+i,b+j);
if(flag==1)printf(">\n");
else if(flag==0)printf("=\n");
else printf("<\n");
}
return 0;
}