//输入8个数,求出最大值与最小值 #include <iostream> using namespace std; int max(int b[],int n),min(int b[],int n); int main() { int a[8]; cout<<"输入8个int型数 :"; for(int i=0;i<8;i++) cin>>a[i]; cout<<"最大数为 "<<max(a,8)<<','<<"最小数为 "<<min(a,8)<<endl; } int max(int b[],int n) { int max=b[0]; for(int i=0;i<n;i++) if(b[i]>max) max=b[i]; return max; } int min(int b[],int n) { int min=b[0]; for(int i=0;i<n;i++) if(b[i]<min) min=b[i]; return min; } <img src="http://img.blog.csdn.net/20150510235151970?watermark/2/text/aHR0cDovL2Jsb2cuY3Nkbi5uZXQvZG91ZG91d2ExMjM0/font/5a6L5L2T/fontsize/400/fill/I0JBQkFCMA==/dissolve/70/gravity/Center" alt="" />
时间: 2024-12-23 12:46:55