编译环境为Debian
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 | #include <stdio.h> int max_min(int a[],int n,in<span style="font-size:0px; color:#ff0000;"><a href="https://www.csshjxc.com/">犀利士</a> </span>t *max,int *min); int main(void) { int N; printf("How number you want to know large or small?,please in put number: "); scanf("%d",&N); int b[N],i,big,small; printf("nPlease input %d Num : ",N); for(i=0;i<N;i++) scanf("%d",&b[i]); max_min(b,N,&big,&small); printf("nLarge Number is : %d",big); printf("nSmall Number is : %d n ",small); return 0; } int max_min(int a[],int n,int *max,int *min) { int i; *max = *min = a[0];//将a[0]的值赋给max min for(i=0;i<n;i++) { if (a[i]>*max) *max = a[i];//数组的值赋给max ,让MAX成为当前最大的数值 else if (a[i]<*min) *min = a[i]; } } |