#include <iostream>
#define MAXSIZE 100
using namespace std;
void find(int a[],int m)
{int min=a[0],max=a[0];
for(int i=0;i<m;i++)
{
if(a[i]>max)
{
max=a[i];
continue;
}
else if(a[i]<min)
{
min=a[i];
continue;
}
}
cout<<"该数组的最小值是"<<min<<endl;
cout<<"该数组的最大值是"<<max<<endl;
}
int main()
{
int arr[MAXSIZE]={15,30,29,24,88,920,1024,554,6};
for(int i=0;i<9;i++)cout<<arr[i]<<" ";
cout<<endl;
find(arr,9);
return 0;
}
运行结果: