/ 科创班 /

记录详情

System Error

/in/foo.c: In function 'main':
/in/foo.c:8:16: warning: implicit declaration of function 'strlen' [-Wimplicit-function-declaration]
     int alen = strlen(a);
                ^~~~~~
/in/foo.c:8:16: warning: incompatible implicit declaration of built-in function 'strlen'
/in/foo.c:8:16: note: include '<string.h>' or provide a declaration of 'strlen'
FormatError('config file not found',)

代码

#include <stdio.h>

int main()
{
    int i;
    char a[101], b[101], c[102] = {0};
    scanf("%s%s", a, b);
    int alen = strlen(a);
    int blen = strlen(b);
    
    for (i = 0; i < alen || i < blen; i++)
    {
        if (i < alen)
            c[i] += a[alen-i-1] - '0';
        if (i < blen)
            c[i] += b[blen-i-1] - '0';
        if (c[i] >= 10)
        {
            c[i+1] = c[i] / 10;
            c[i] %= 10;
        }
    }
    if (alen < blen) alen = blen;
    if (c[alen] > 0) printf("%d", c[alen]);
    for (i = alen - 1; i >= 0; i--)
        printf("%d", c[i]);
    return 0;
}

信息

递交者
类型
递交
题目
高精度加法
题目数据
下载
语言
C
递交时间
2018-10-17 21:00:17
评测时间
2018-10-17 21:00:17
评测机
分数
0
总耗时
0ms
峰值内存
0 Bytes