Advertisement
HugoBallee

GLIN202/TP2/exo7

Feb 5th, 2013
71
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.73 KB | None | 0 0
  1. // Hugo Gallée
  2. // TP2/exo7.c
  3. // Creer un nouveau programme qui calcule le maximum de 3 entiers saisis au clavier
  4. // et qui affiche le maximum et le minimum a l'ecran.
  5.  
  6. #include <stdio.h>
  7. #include <stdlib.h>
  8.  
  9.  
  10. int main()
  11. {
  12.     int a, b, c, min, max;
  13.  
  14.     a = lire_entier(a);
  15.     b = lire_entier(b);
  16.     c = lire_entier(c);
  17.  
  18.     // Trouver le maximum
  19.     if ((a > b) && (a > c)) { // Si a est le plus grand
  20.         max = a;
  21.     } else if (b > c) { // Sinon, si b est le plus grand
  22.         max = b;
  23.     } else { // Sinon, c est le plus grand
  24.         max = c;
  25.     }
  26.  
  27.     // Trouver le minimum de la meme facon
  28.     if ((a < b) && (a < c)) {
  29.         min = a;
  30.     } else if (b < c) {
  31.         min = b;
  32.     } else {
  33.         min = c;
  34.     }
  35.  
  36.     printf("min: %d, max: %d\n", min, max);
  37.  
  38.     return 0;
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement