记录详情

Runtime Error

/in/foo.c: In function 'sumup':
/in/foo.c:51:12: warning: 'sum' may be used uninitialized in this function [-Wmaybe-uninitialized]
     return sum;
            ^~~
/in/foo.c: In function 'main':
/in/foo.c:66:5: warning: 'sum' may be used uninitialized in this function [-Wmaybe-uninitialized]
     printf("%lld",sum);
     ^~~~~~~~~~~~~~~~~~
# 状态 耗时 内存占用
#1 Wrong Answer 0ms 216.0 KiB
#2 Wrong Answer 0ms 216.0 KiB
#3 Wrong Answer 0ms 128.0 KiB
#4 Wrong Answer 1ms 216.0 KiB
#5 Runtime Error 4ms 128.0 KiB
#6 Runtime Error 8ms 220.0 KiB
#7 Runtime Error 4ms 220.0 KiB
#8 Runtime Error 9ms 208.0 KiB
#9 Runtime Error 7ms 212.0 KiB
#10 Runtime Error 11ms 216.0 KiB

代码

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int seek(int n,int num[])
{
    int i,k,find;
    int j=1;
    for(k=3; k<=n; k++)//待判定数
    {
        find = 1;
        for(i=2; i<=sqrt(k); i++)
        {
            if(k%i == 0)
                find=0;
        }
        if(find == 1)
        {
            num[j] = k;
            j++;
        }
    }
    return j-1;
}

int  yesorno(int n,int x)
{
    int i=x;
    while(x<=n)
    {
        x = x * i;
    }
    return x/i;
}

void mutiple(int n,int num[],int k)
{
    int i;
    for(i=0; i<=k ; i++)
    {
        num[i] = yesorno(n,num[i]);
    }
}
long long  sumup(int k,int num[])
{
    int i ;
    long long sum;
    for(i=0;i<=k;i++)
    {
        sum = sum * num[i];
    }
    return sum;
}

int main()
{
    int n,j;
    long long sum;
    int num[1000];
    num[0] = 2;
    scanf("%d",&n);
    j = seek(n,num);

    mutiple(n,num,j);

    sum = sumup(j,num);
    printf("%lld",sum);
    return 0;
}

信息

递交者
类型
递交
题目
篝题
语言
C
递交时间
2020-12-23 23:32:50
评测时间
2020-12-23 23:32:50
评测机
分数
0
总耗时
50ms
峰值内存
220.0 KiB