APL/APL1.1/TP06/couverture.c

40 lines
775 B
C
Raw Normal View History

2021-09-24 10:19:20 +02:00
#include<stdio.h>
#include<stdlib.h>
int min(int a, int b) {
return a < b ? a : b;
}
int max(int a, int b) {
return a > b ? a : b;
}
int main(int argc, char * argv[]) {
int frais, result;
printf("Veuillez indiquer le montant total des réparations : ");
result = scanf("%d", &frais);
if (result != 1) {
printf("Format invalide.\n");
return EXIT_FAILURE;
}
int part_assure, part_assurance;
if ( frais <= 200 ) {
part_assure = frais;
part_assurance = 0;
} else if (frais <= 2000) {
part_assure = 200;
part_assurance = frais - 200;
} else {
part_assure = min(frais/10, 800);
part_assurance = frais - part_assure;
}
printf("L'assuré prendra en charge %d€ et l'assurance %d€.\n", part_assure, part_assurance);
return EXIT_SUCCESS;
}