1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34
| #include <stdio.h> // On en a besoin pour pouvoir utiliser printf et scanf.
int main()
{
// Étape 1 : Récupérer 3 entiers saisis par l'utilisateur.
int a = 0, b = 0, c = 0;
printf("Veuillez saisir trois nombres entiers : ");
scanf("%d %d %d", &a, &b, &c);
// Étape 2 : Trier ces 3 entiers dans l'ordre croissant.
if(a > b) {
// Échanger a et b.
int tmp = a;
a = b;
b = tmp;
}
if(b > c) {
// Échanger b et c.
int tmp = b;
b = c;
c = tmp;
}
if(a > b) {
// Échanger a et b.
int tmp = a;
a = b;
b = tmp;
}
// Étape 3 : Afficher ces 3 entiers.
printf("Voici vos nombres dans l'ordre croissant : %d %d %d\n", a, b, c);
return 0;
} |