都好几天了都找不到错哪了,谁给看看?
#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)
谁给看看是哪里出错了;这题都3,4天了还没有找到问题; 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;
}
小于等于中间不能有空格
页:
[1]