请教大佬们,为什么清理缓冲区和没清理缓冲区都能通过呀?那什么时候要清理缓冲区呀?
查看原帖
请教大佬们,为什么清理缓冲区和没清理缓冲区都能通过呀?那什么时候要清理缓冲区呀?
371253
qinlei楼主2022/3/9 11:38
#include<stdio.h>
#include<string.h>
char s1[505], s2[505];
    int a[505], b[505], c[505];
int main()
{
    int la, lb, lc;
    scanf("%s", s1);
    char t;
    scanf("%c", &t);
    scanf("%s", s2);
    la = strlen(s1);
    lb = strlen(s2);
    for (int i = 0; i < la; i++)
        a[la - i] = s1[i] - '0';
    for (int i = 0; i < lb; i++)
        b[lb - i] = s2[i] - '0';
    if (la > lb)
        lc = la + 1;
    else
        lc = lb + 1;
    for (int i = 1; i <= lc; i++)
    {
        c[i] += a[i] + b[i];
        c[i + 1] = c[i] / 10;
        c[i] = c[i] % 10;
    }
    if (c[lc] == 0 && lc > 0)
        lc--;
    for (int i = lc; i > 0; i--)
        printf("%d", c[i]);
    return 0;
}
2022/3/9 11:38
加载中...