A C++ problem about array
登录 | 论坛导航 -> 华新鲜事 -> 求学狮城 | 本帖共有 11 楼,当前显示第 4 楼 : 从楼主开始阅读 : 本帖树形列表 : 返回上一页
作者:我行故我 (等级:5 - 略有小成,发帖:1333) 发表:2003-05-13 17:40:28  4楼 
come in>>
do u mean to find the max number of an array whoes size is 10?
if so..
I changed ur program a bit..
u can see the difference..


#include<iostream.h>
int max_element(int[], int);
void main(){
int n, a[10];
int max;
for(n=0; n<10; n ++)
cin>>a[n];
max=max_element(a, 10);
cout<<max;
cout<<endl;
}
int max_element(int array[] , int size){
int temp, j;
temp = array[0];
for(j=0; j<size; j++)
if(temp<array[j])
temp=array[j];
return temp;
}




Don't forget to always have a dream
我曾是孤单的飞鸟
飘荡在远方的天空
如今我已飞得太久
才知道我就是春天
我用力地挥动翅膀
开始寻找家的方向
我用力地挥动翅膀
溶进这宽阔的天空
欢迎来到华新中文网,踊跃发帖是支持我们的最好方法!原文 / 传统版 / WAP版只看此人从这里展开收起列表

本帖共有 11 楼,当前显示第 4 楼,本文还有 N-1 层楼,要不你试试看:点击此处阅读更多 >>



请登录后回复:帐号   密码