36 lines
612 B
C
36 lines
612 B
C
#include<stdio.h>
|
|
#include<stdlib.h>
|
|
|
|
int main(int argc, char * argv[]) {
|
|
|
|
double somme;
|
|
printf("Saisissez le montant de votre paiement : ");
|
|
scanf("%lf", &somme);
|
|
|
|
int piece2 = 0;
|
|
int piece20 = 0;
|
|
int piece1 = 0;
|
|
|
|
while (somme >= 2) {
|
|
somme -= 2;
|
|
piece2++;
|
|
}
|
|
|
|
while (somme >= 0.2f) {
|
|
somme -= 0.2f;
|
|
piece20++;
|
|
}
|
|
|
|
while (somme >= 0.01f) {
|
|
somme -= 0.01f;
|
|
piece1++;
|
|
}
|
|
|
|
printf("Il vous faudra %d pièce%s de 2€, %d pièce%s de 20¢ et %d piece%s de 1¢.\n",
|
|
piece2, piece2 > 1 ? "s" : "", piece20, piece20 > 1 ? "s" : "",
|
|
piece1, piece1 > 1 ? "s" : "");
|
|
|
|
return EXIT_SUCCESS;
|
|
}
|
|
|