APL/APL1.1/TP06/maximum.c

42 lines
729 B
C
Raw Normal View History

2021-09-24 10:19:20 +02:00
#include<stdio.h>
#include<stdlib.h>
int proposeInt() {
printf("Veuillez donner un entier : ");
}
int checkResult(int result) {
if (result == 0) {
printf("Format Incorrect.\n");
return 0;
}
return 1;
}
int main(int argc, char * argv[]) {
int max, min;
printf("%d", &max);
proposeInt();
int result1 = scanf("%d", &max);
if (!checkResult(result1)) return EXIT_FAILURE;
proposeInt();
int result2 = scanf("%d", &min);
if (!checkResult(result2)) return EXIT_FAILURE;
max = max>min ? max : min;
proposeInt();
int result3 = scanf("%d", &min);
if (!checkResult(result3)) return EXIT_FAILURE;
max = max>min ? max : min;
printf("Le maximum de ces trois valeurs est %d.\n", max);
return EXIT_SUCCESS;
}