Advertisement
Superloup10

Plus_ou_moins

Apr 24th, 2016
111
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 6.78 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <stdlib.h>
  3. #include <time.h>
  4. #include <string.h>
  5. #define WindowsVista
  6. int main()
  7. {
  8.     char rejouer[100];
  9.     char vrai[] = "oui";
  10.     do
  11.     {
  12.         int demande = 0;
  13.         int coups = 0;
  14.         int nombreDeJoueurs = 1;
  15.         srand(time(NULL));
  16.  
  17.         printf("Nombre de Joueurs : ");
  18.         scanf("%d", &nombreDeJoueurs);
  19.         if(nombreDeJoueurs == 1)
  20.         {
  21.             char difficultee[100];
  22.             char facile[] = "facile";
  23.             char moyen[] = "moyen";
  24.             char difficile[] = "difficile";
  25.             char expert[] = "expert";
  26.             char legendaire[] = "legendaire";
  27.  
  28.             printf("Niveau de difficultee :\n");
  29.             printf("- facile\n");
  30.             printf("- moyen\n");
  31.             printf("- difficile\n");
  32.             printf("- expert\n");
  33.             printf("- legendaire\n\n");
  34.             scanf("%s", difficultee);
  35.             #ifdef WindowsVista
  36.             system("cls");
  37.             #endif // WindowsVista
  38.             #ifdef Linux
  39.             system("clear");
  40.             #endif // Linux
  41.             if(strcmp(difficultee, facile) == 0)
  42.             {
  43.                 const int MAX = 100, MIN = 0;
  44.                 int aleatoire = (rand() % (MAX - MIN + 1) + MIN);
  45.                 do
  46.                 {
  47.                     coups = coups + 1;
  48.                     printf("Entrer un nombre : ");
  49.                     scanf("%d", &demande);
  50.                     if(demande < aleatoire)
  51.                     {
  52.                         printf("C\'est plus !\n");
  53.                     }
  54.                     else if(demande > aleatoire)
  55.                     {
  56.                         printf("C\'est moins !\n");
  57.                     }
  58.                     else
  59.                     {
  60.                         printf("Vous avez gagner en %d coups\n\n", coups);
  61.                     }
  62.                 }while(demande != aleatoire);
  63.             }
  64.             else if(strcmp(difficultee, moyen) == 0)
  65.             {
  66.                 const int MAX = 1000, MIN = 0;
  67.                 int aleatoire = (rand() % (MAX - MIN + 1) + MIN);
  68.                 do
  69.                 {
  70.                     coups = coups + 1;
  71.                     printf("Entrer un nombre :");
  72.                     scanf("%d", &demande);
  73.                     if(demande < aleatoire)
  74.                     {
  75.                         printf("C\'est plus !\n");
  76.                     }
  77.                     else if(demande > aleatoire)
  78.                     {
  79.                         printf("C\'est moins !\n");
  80.                     }
  81.                     else
  82.                     {
  83.                         printf("Vous avez gagner en %d coups\n\n", coups);
  84.                     }
  85.                 }while(demande != aleatoire);
  86.             }
  87.             else if(strcmp(difficultee, difficile) == 0)
  88.             {
  89.                 const int MAX = 10000, MIN = 0;
  90.                 int aleatoire = (rand() % (MAX - MIN + 1) + MIN);
  91.                 do
  92.                 {
  93.                     coups = coups + 1;
  94.                     printf("Entrer un nombre :");
  95.                     scanf("%d", &demande);
  96.                     if(demande < aleatoire)
  97.                     {
  98.                         printf("C\'est plus !\n");
  99.                     }
  100.                     else if(demande > aleatoire)
  101.                     {
  102.                         printf("C\'est moins !\n");
  103.                     }
  104.                     else
  105.                     {
  106.                         printf("Vous avez gagner en %d coups\n\n", coups);
  107.                     }
  108.                 }while(demande != aleatoire);
  109.             }
  110.             else if(strcmp(difficultee, expert) == 0)
  111.             {
  112.                 const int MAX = 10000, MIN = -10000;
  113.                 int aleatoire = (rand() % (MAX - MIN + 1) + MIN);
  114.                 do
  115.                 {
  116.                     coups = coups + 1;
  117.                     printf("Entrer un nombre :");
  118.                     scanf("%d", &demande);
  119.                     if(demande < aleatoire)
  120.                     {
  121.                         printf("C\'est plus !\n");
  122.                     }
  123.                     else if(demande > aleatoire)
  124.                     {
  125.                         printf("C\'est moins !\n");
  126.                     }
  127.                     else
  128.                     {
  129.                         printf("Vous avez gagner en %d coups\n\n", coups);
  130.                     }
  131.                 }while(demande != aleatoire);
  132.             }
  133.             else if(strcmp(difficultee, legendaire) == 0)
  134.             {
  135.                 long demande = 0;
  136.                 const long MAX = 1000000, MIN = -1000000;
  137.                 long aleatoire = (rand() % (MAX - MIN + 1) + MIN);
  138.                 do
  139.                 {
  140.                     coups = coups + 1;
  141.                     printf("Entrer un nombre :");
  142.                     scanf("%ld", &demande);
  143.                     if(demande < aleatoire)
  144.                     {
  145.                         printf("C\'est plus !\n");
  146.                     }
  147.                     else if(demande > aleatoire)
  148.                     {
  149.                         printf("C\'est moins !\n");
  150.                     }
  151.                     else
  152.                     {
  153.                         printf("Vous avez gagner en %d coups\n\n", coups);
  154.                     }
  155.                 }while(demande != aleatoire);
  156.             }
  157.         }
  158.         else if(nombreDeJoueurs == 2)
  159.         {
  160.             int mystere;
  161.             printf("Joueur 1 : Entrer le nombre mystere : ");
  162.             scanf("%d", &mystere);
  163.             #ifdef WindowsVista
  164.             system("cls");
  165.             #endif // WindowsVista
  166.             #ifdef Linux
  167.             system("clear");
  168.             #endif // Linux
  169.             do
  170.             {
  171.                 coups = coups + 1;
  172.                 printf("Joueur 2 : Entrer un nombre : ");
  173.                 scanf("%d", &demande);
  174.                 if(demande < mystere)
  175.                 {
  176.                     printf("C\'est plus !\n");
  177.                 }
  178.                 else if(demande > mystere)
  179.                 {
  180.                     printf("C\'est moins !\n");
  181.                 }
  182.                 else
  183.                 {
  184.                     printf("Vous avez gagner en %d coups\n\n", coups);
  185.                 }
  186.             }while(demande != mystere);
  187.         }
  188.         printf("Voulez-vous rejouer ?\n");
  189.         printf("- oui\n");
  190.         printf("- non\n\n");
  191.         scanf("%s", rejouer);
  192.         #ifdef WindowsVista
  193.         if(strcmp(rejouer, vrai) == 0)
  194.         {
  195.             system("cls");
  196.         }
  197.         #endif // WindowsVista
  198.         #ifdef Linux
  199.         if(strcmp(rejouer, vrai) == 0)
  200.         {
  201.             system("clear");
  202.         }
  203.         #endif // Linux
  204.     }while(strcmp(rejouer, vrai) == 0);
  205.     return 0;
  206. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement