c++ 求数组中元素最大值的函数(1)
来源:百度知道 编辑:UC知道 时间:2024/05/16 07:21:44
题中给定了数组z[] 和数组元素个数n
用c++ 求数组中元素最大值的函数
小弟c还可以 但多了++就一窍不通了 请各位大虾指点下哈
每句后面帮我注释下句子意思 谢谢了!!!!
我要程序哈!
用c++ 求数组中元素最大值的函数
小弟c还可以 但多了++就一窍不通了 请各位大虾指点下哈
每句后面帮我注释下句子意思 谢谢了!!!!
我要程序哈!
示例:以int 数组为例
int max_int(int *array,int n)//array 为int类型的数组的指针 ,n为数组元素个数
{
int max = array[0];
for(int i= 0;i< n ;i++)
{
if(max < array[i])
{
max = array[i];
}
}
return max;
}
int CheckMax(int z[],int n)
{
int max=z[0];
for(int i=0;i<=n;i++) if (max>z[i]) max=z[i];
return z[i];
}
非的++的话。
class Max
{
private:
int z[];
int n;
int max;
pu