Advertisement
Guest User

Exercice 1401

a guest
Oct 10th, 2019
87
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3.  
  4. //Création du sous-programme permettant d'obtenir le menu
  5. int menu()
  6. {
  7.     int choix = 4;
  8.  
  9.     //Blindage
  10.     while (choix < 0 || choix > 3)
  11.     {
  12.         printf("Menu :\n");
  13.         printf("1 : Nouvelle partie\n");
  14.         printf("2 : Continuer\n");
  15.         printf("3 : Voir les scores\n");
  16.         printf("0 : Quitter\n");
  17.         printf("Votre choix ? ");
  18.         scanf("%d", &choix);
  19.     }
  20.  
  21.     return choix;
  22. }
  23.  
  24. //Programme principal utilisant le sous-programme
  25. int main()
  26. {
  27.     switch (menu())
  28.     {
  29.         case 1:
  30.             printf("Nouvelle partie !\n");
  31.             break;
  32.         case 2:
  33.             printf("On continue !\n");
  34.             break;
  35.         case 3:
  36.             printf("Voici les résultats\n");
  37.             break;
  38.         case 0:
  39.             printf("Au revoir !\n");
  40.             break;
  41.     }
  42.  
  43.     return 0;
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement