#include <stdio.h> void findByPoint(int *, int, int *, int *); void find(int *a, int n, int max, int min); int main(void) { int max1=0, min1=0, a[]={5,3,7,9,2,0,4,1,6,8}; findByPoint(a,10,&max1,&min1); printf("Êý×éa×î´óºÍ×îСԪËØϱêÊÇ%d,%d\n", max1, min1); int max2=0, min2=0,b[]={3,4,71,9,2,7,4,2,6,90}; find(b,10,max2,min2); printf("Êý×éb×î´óºÍ×îСԪËØϱêÊÇ%d,%d\n", max2, min2); return 0; } void findByPoint(int *a, int n, int *max, int *min) { int i; *max=*min=0; for (i = 1; i < n; i++) { if (a[i] > a [*max]) *max=i; if (a[i] < a [*min]) *min=i; } } void find(int *a, int n, int max, int min) { int i; for (i = 1; i < n; i++) { if (a[i] > a [max]) max=i; if (a[i] < a [min]) min=i; } printf("Êý×éb×î´óºÍ×îСԪËØϱêÊÇ%d,%d\n", max, min); }