zhaoanqiEtayo @ 2023-08-07 10:49:55
void sum(int n) {
int a = 1;
for (int i = 1; i <= n; i++)
{
a = a * i;
}
return a;
}
int main()
{
int n;
scanf("%d", &n);
printf("%d",sum(n));
return 0;
}
by hexuchen @ 2023-08-07 10:50:41
@zhaoanqiEtayo 没加头文件
by hexuchen @ 2023-08-07 10:51:14
@zhaoanqiEtayo 函数名是void,不能有返回值
by ForEly @ 2023-08-07 10:53:14
@zhaoanqiEtayo
void函数不能返回一个值 请把它改成int
by robot_steve @ 2023-08-07 10:53:43
@zhaoanqiEtayo 你把void改成int就能过编译
by _Adolf_Hitler_ @ 2023-08-07 10:59:07
@zhaoanqiEtayo 有返回值就别用void
by xiaoshuaibi @ 2023-08-07 11:05:45
void用return;他是无返回函数