#include
long int FindMax(array[15]);//这里定义函数在括号里要不要加数组名?如果加,要不要带括号?
int main ()
{
long int array[15];
long int Max;
printf("Please input 15 numbers:\n");
int i;
for(i = 1;i <= 15;i++)
{
scanf("%d",&array[i]);
}
Max = long int FindMax(array);
printf("The max is %d in the array.",Max);
return 0;
}
long int FindMax (array)
{
long int maxnumber,x = array[0];
int i;
for (i = 0;i<=15;i++)
{
if array[i]>=array[0];
maxnumber = array[i];
}
return maxnumber;
}
这是提示错误
2 18 C:\Users\86133\Desktop?沂?组?畲?.cpp [Error] 'array' was not declared in this scope
C:\Users\86133\Desktop\找数?樽?大.cpp In function 'int main()':
13 8 C:\Users\86133\Desktop\找??最??cpp [Error] expected primary-expression before 'long'
C:\Users\86133\Desktop\找??最??cpp At global scope:
17 10 C:\Users\86133\Desktop?沂?组?畲?.cpp [Error] redefinition of 'long int FindMax'
2 10 C:\Users\86133\Desktop\找??最??cpp [Note] 'long int FindMax' previously defined here
17 19 C:\Users\86133\Desktop?沂?组?畲?.cpp [Error] 'array' was not declared in this scope
函数你没有指定参数类型啊
long int FindMax(array[15])改为
long int FindMax(long int array[15])
18行也改成
long int FindMax (long int array[15])
14行改成
Max =FindMax(array);