编译出错,求帮助
#include<stdio.h>int gcd (int x, int y);
int gcds(int *array,int len);
int main(void)
{
int n;
scanf("%d",&n);
int array[n];
for(int idx=0;idx<n;idx++)
{
scanf("%d",&array[idx]);
}
int now = gcds(array,n);
printf("%d",now);
return 0;
}
intgcd(int x,int y)
{
if(y!=0)
return gcd(y,x%y);
else
return x;
}
int gcds(int *array,int len)
{
if(len!=0)
return gcd(*array,gcds(array+1,len-1));
else
return *array
}
--------------------Configuration: 333 - Win32 Debug--------------------
Compiling...
333.C
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(8) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(9) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(9) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(9) : error C2143: syntax error : missing ')' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(9) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(9) : error C2065: 'idx' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(9) : warning C4552: '<' : operator has no effect; expected operator with side-effect
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(9) : error C2059: syntax error : ')'
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(10) : error C2143: syntax error : missing ';' before '{'
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(11) : error C2065: 'array' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(11) : error C2109: subscript requires array or pointer type
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(11) : error C2102: '&' requires l-value
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(13) : error C2143: syntax error : missing ';' before 'type'
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(14) : error C2065: 'now' : undeclared identifier
C:\Program Files\Microsoft Visual Studio\MyProjects\333\333.C(30) : error C2143: syntax error : missing ';' before '}'
执行 cl.exe 时出错.
333.exe - 1 error(s), 0 warning(s)