29 lines
496 B
C
29 lines
496 B
C
|
#include<stdlib.h>
|
||
|
#include<stdio.h>
|
||
|
|
||
|
int main(void) {
|
||
|
|
||
|
int reponse,resultat;
|
||
|
|
||
|
printf("Triple\n-------\nLa valeur retourner sera celle du multiple de 3 le plus proche de votre valeur.\nVotre valeur : ");
|
||
|
scanf("%d", &reponse);
|
||
|
|
||
|
|
||
|
if(reponse%3 == 0){
|
||
|
resultat = reponse;
|
||
|
}
|
||
|
|
||
|
else {
|
||
|
if(reponse%3 == 1){
|
||
|
resultat = reponse-1;
|
||
|
}
|
||
|
else
|
||
|
resultat = reponse+1;
|
||
|
}
|
||
|
|
||
|
printf("Le multiple de 3 le plus proche de %d est %d\n",reponse,resultat);
|
||
|
|
||
|
|
||
|
return EXIT_SUCCESS;
|
||
|
}
|