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:64:5: warning: 'sum' may be used uninitialized in this function [-Wmaybe-uninitialized] printf("%d",sum % 1000000007); ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~
代码
#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]);
}
}
int sumup(int k,int num[])
{
int i ;
int sum;
for(i=0;i<=k;i++)
{
sum = sum * num[i];
}
return sum;
}
int main()
{
int n,j;
int sum;
int num[1000];
num[0] = 2;
scanf("%d",&n);
j = seek(n,num);
mutiple(n,num,j);
sum = sumup(j,num);
printf("%d",sum % 1000000007);
return 0;
}
信息
- 递交者
- 类型
- 递交
- 题目
- 篝题
- 语言
- C
- 递交时间
- 2020-12-23 23:38:46
- 评测时间
- 2020-12-23 23:38:46
- 评测机
- 分数
- 0
- 总耗时
- 35ms
- 峰值内存
- 228.0 KiB