求1!+2!+……+10!,不知道是哪里错了,求高手指点!
求1!+2!+……+10!#include<stdio.h>
void main(){
int f(int p);
int n , s;
scanf("%d",&n);
s=f(n);
printf("s=%d\n",s);
}
int f(int p){
int m = 1,s = 0;
for(int i = 1;i<=p; i++){
m = m * i;
s = s + m;
}
return (s);
}
编译时的错误提示:--------------------Configuration: 2 - Win32 Debug--------------------
Compiling...
2.c
D:\Program Files (x86)\vc++\新建文件夹\MSDev98\Bin\2.c(11) : error C2143: syntax error : missing ';' before 'type'
D:\Program Files (x86)\vc++\新建文件夹\MSDev98\Bin\2.c(11) : error C2143: syntax error : missing ';' before 'type'
D:\Program Files (x86)\vc++\新建文件夹\MSDev98\Bin\2.c(11) : error C2143: syntax error : missing ')' before 'type'
D:\Program Files (x86)\vc++\新建文件夹\MSDev98\Bin\2.c(11) : error C2143: syntax error : missing ';' before 'type'
D:\Program Files (x86)\vc++\新建文件夹\MSDev98\Bin\2.c(11) : error C2065: 'i' : undeclared identifier
D:\Program Files (x86)\vc++\新建文件夹\MSDev98\Bin\2.c(11) : warning C4552: '<=' : operator has no effect; expected operator with side-effect
D:\Program Files (x86)\vc++\新建文件夹\MSDev98\Bin\2.c(11) : error C2059: syntax error : ')'
D:\Program Files (x86)\vc++\新建文件夹\MSDev98\Bin\2.c(11) : error C2143: syntax error : missing ';' before '{'
Error executing cl.exe.
2.obj - 7 error(s), 1 warning(s)