Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // Hugo Gallée
- // TP2/exo7.c
- // Creer un nouveau programme qui calcule le maximum de 3 entiers saisis au clavier
- // et qui affiche le maximum et le minimum a l'ecran.
- #include <stdio.h>
- #include <stdlib.h>
- int main()
- {
- int a, b, c, min, max;
- a = lire_entier(a);
- b = lire_entier(b);
- c = lire_entier(c);
- // Trouver le maximum
- if ((a > b) && (a > c)) { // Si a est le plus grand
- max = a;
- } else if (b > c) { // Sinon, si b est le plus grand
- max = b;
- } else { // Sinon, c est le plus grand
- max = c;
- }
- // Trouver le minimum de la meme facon
- if ((a < b) && (a < c)) {
- min = a;
- } else if (b < c) {
- min = b;
- } else {
- min = c;
- }
- printf("min: %d, max: %d\n", min, max);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement