URAL 1048 Superlong Sums

URAL_1048

    高精度加法。

#include<stdio.h>
#include<string.h>
#define MAXD 1000010
int a[MAXD], N;
void solve()
{
    int i, x, y, s, c;
    for(i = 0; i < N; i ++)
    {
        scanf("%d%d", &x, &y);
        a[i] = x + y;
    }
    c = 0;
    for(i = N - 1; i >= 0; i --)
    {
        s = c + a[i];
        c = s / 10;
        a[i] = s % 10;
    }
    for(i = 0; i < N; i ++)
        printf("%d", a[i]);
    printf("\n");
}
int main()
{
    while(scanf("%d", &N) == 1)
    {
        solve();
    }
    return 0;
}
原文地址:https://www.cnblogs.com/staginner/p/2487151.html