#include<stdio.h>
int minmax(int a[], int len, int *max, int *min);
int main() {
int a[10] = { 5,4,3,2,1,6,7,8,9,10 };
int max, min;
minmax(a, sizeof(a) / sizeof(a[0]), &max, &min);
printf("max = %d, min = %d", max, min);
return 0;
}
int minmax(int a[], int len, int *max, int *min) {
int i;
*min = *max = a[0];
for ( i = 0; i < len; i++)
{
if (a[i]<*min)
*min = a[i];
if (a[i] > *max)
*max = a[i];
}
return 0;
}