Hi, how short can this code be reduced to? | Sololearn: Learn to code for FREE!
Novo curso! Todo programador deveria aprender IA generativa!
Experimente uma aula gr√°tis
0

Hi, how short can this code be reduced to?

#include <stdio.h> #define N 10 void max_min(int a[], int n, int *max, int *min) { int i; *max = *min = a[0]; for (i = 0; i < n; i++) { if (a[i] > *max) *max = a[i]; else if (a[i] < *min) *min = a[i]; } } int main() { int b[N], i, big,small; printf("Enter %d numbers: ", N); for(i = 0; i<N; i++) scanf("%d", &b[i]); max_min(b, N, &big, &small); printf("Largest :%d\n", big); printf("Smallest :%d\n", small); return 0; }

25th Jun 2018, 2:58 AM
Don Loic
1 Resposta
+ 1
Thanks ūüĎĆ
25th Jun 2018, 3:39 AM
Don Loic