大神给看看错哪里了
本帖最后由 谁能不死 于 2019-10-29 11:27 编辑#include <stdio.h>
long square(int p);
long factorial(int q);
void main()
{
int i;
long s = 0;
for(i = 2; i < = 3; i++)
{
s = s + square(i);
}
printf("%ld\n",s);
}
long square(int p)
{
int k;
long r;
long factorial(int);
k = p * p;
r = factorial(k);
return r;
}
long factorial(int q)
{
long c=1;
int i;
for(i=1;i<=q;i++)
{
c *= i;
}
return c;
}
对着视频抄的,可是编译却报错了,对着视频对了很久,也没有找到错哪里了;大神给看看到底是哪里错;
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\hanshu7\hanshu7.c(8) : error C2059: syntax error : '='
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\hanshu7\hanshu7.c(8) : error C2143: syntax error : missing ';' before ')'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\hanshu7\hanshu7.c(12) : error C2143: syntax error : missing ')' before 'string'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\hanshu7\hanshu7.c(12) : error C2143: syntax error : missing '{' before 'string'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\hanshu7\hanshu7.c(12) : error C2059: syntax error : '<Unknown>'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\hanshu7\hanshu7.c(12) : error C2059: syntax error : ')'
C:\Program Files (x86)\Microsoft Visual Studio\MyProjects\hanshu7\hanshu7.c(13) : error C2059: syntax error : '}'
执行 cl.exe 时出错.
hanshu7.obj - 1 error(s), 0 warning(s)
main涵数中,for()里面的<=这运算符中间多了个空格,应删除一下
页:
[1]