莫名WA两个点,求大佬指教

P1303 A*B Problem

BCtt_YDLee @ 2018-03-09 00:34:03

感觉自己写的什么问题都没有然后就莫名的开始WA

放代码


#include <cstdlib>
#include <cstdio>
#include <iostream>
#include <cstring>

using namespace std;

char a1[5005], b1[5005];
int a[5005], b[5005], c[10005], lena, lenb, lenc, x;

int main()
{
    scanf("%s", a1);
    lena = strlen(a1);
    for(int i = 0; i < lena; i++)
        a[lena - i - 1] = a1[i] - '0';
    scanf("%s", b1);
    lenb = strlen(b1);
    for(int i = 0; i < lenb; i++)
        b[lena - i - 1] = b1[i] - '0';
    for(int i = 0; i < lena; i++)
        for(int j = 0; j < lenb; j++)
            c[i + j] += a[i] * b[j];
    lenc = lena + lenb + 1;
    for(int i = 0; i < lenc - 1; i++)
    {
        c[i + 1] += c[i] / 10;
        c[i] %= 10;
    }
    while(c[lenc - 1] == 0 && lenc > 1)
        -- lenc;
    for(int i = lenc - 1; i >= 0; i--)
        printf("%d", c[i]); 
    return 0;
}

|