您的位置:首页 > 其它

CodeForces 616 A. Comparing Two Long Integers(水~)

2016-02-26 11:08 281 查看
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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: