C++编程序的问题

来源:百度知道 编辑:UC知道 时间:2024/06/06 09:11:58
这是一道求最大值的问题,有十个错
能不能帮我找找哪些地方错了?
谢谢
求求你们了
急死了!

#include<stdio.h>
int main()
{

void max(int numbers[][]);
int numbers[5][5]={78,89,85,96,33,
17,58,74,96,44,
58,96,55,99,77,
89,48,57,59,94,
54,41,48,14,69};
int MAX;

MAX=max(int numbers[][]);

printf("The max of the numbers[5][5] is %d\n",MAX);

return 0;
}

void max(int numbers[][])
{
int i,j;

max=numbers[0][0];

for(i=1;i<=5;i++)
{
for(j=1;j<=5;j++)
{
if(max>=numbers[i][j])
max=max;
else
max=numbers[i][j];
}
}

}
应该怎么改啊?
(5) : error C2087: '<Unknown>' : missing subscript
(13) : error C2144: syntax error : missing ')' before type 'int'
(13) : error C2660: 'max' : function does not tak

#include<stdio.h>
int main()
{

int max(int numbers[][5]);
int numbers[5][5]={78,89,85,96,33,
17,58,74,96,44,
58,96,55,99,77,
89,48,57,59,94,
54,41,48,14,69};
int MAX;

MAX=max(numbers);

printf("The max of the numbers[5][5] is %d\n",MAX);

return 0;
}

int max(int numbers[][5])
{
int i,j;
int max;

max=numbers[0][0];

for(i=0;i<=4;i++)
{
for(j=0;j<=4;j++)
if(max<numbers[i][j])
max=numbers[i][j];
}
return max;

}

这样就好了 你二维数组参数那里错误

把编译器的错误提示贴出来好找一些
max调用不用写 int
还有,max既为函数名又为变量名
二维数组作参数,形参应该把第二维写出来,我记得

int numbers[][] 这种声明二维数组的方法是不对的

因为编译器 不能确定 二维数组的组织结构 比如一行有多少个元素(列)

所以 声明二维数组时一定要加上列数 如int numbers[][10];

类似 声明三维数组时,后面的两项也要加上 如; int numbers[][10][10];

这样编译器才能理解数组是怎样组织的

ewde