Educational Codeforces Round 5 A

Problem A:http://codeforces.com/contest/616/problem/A

A. Comparing Two Long Integers

果然还是我太天真了(长整数比较不就是long long么........于是一直wa on 9,直到今天起床看了看别人的代码才恍然大悟。。。

#include<stdio.h>  
#include<string.h>  
const int MAX_N = 1000005;  
  
int main(){  
    char a[MAX_N],b[MAX_N];  
    int lena,lenb,la,lb,pa=0,pb=0,i;  
    scanf("%s%s",a,b);  
    lena=strlen(a);  
    lenb=strlen(b);  
    while(pa<lena&&a[pa]=='0') pa++;  
    while(pb<lenb&&b[pb]=='0') pb++;  
    la=lena-pa;  
    lb=lenb-pb;  
    if(la>lb)  
    printf(">
");  
    else if(la<lb)  
    printf("<
");  
    else{  
        for(i=pa;i<lena;i++){  
            if(a[i]>b[i-pa+pb]){  
            printf(">
");  
            return 0;  
            }  
            else if(a[i]<b[i-pa+pb]){  
                printf("<
");  
                return 0;  
            }  
        }  
        printf("=
");  
    }  
    return 0;  
}
我会一直在
原文地址:https://www.cnblogs.com/zhien-aa/p/5167652.html