40 lines
775 B
C
40 lines
775 B
C
|
#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;
|
||
|
}
|
||
|
|