efrei/programmation-c-cpp/tp5/min_max.c

34 lines
458 B
C
Raw Normal View History

2021-11-29 08:30:51 +01:00
/* Minimum, maximum */
#include <stdio.h>
#include <stdlib.h>
int min(int, int);
int max(int, int);
int main() {
int a, b;
a = 12;
b = 9;
printf("Le min de %d et %d est %d\n", a, b, min(a, b));
printf("Le max de %d et %d est %d\n", a, b, max(a, b));
return 0;
}
int min(int a, int b) {
if (a <= b) {
return a;
}
return b;
}
int max(int a, int b) {
if (a >= b) {
return a;
}
return b;
}