Advertisement
Guest User

Untitled

a guest
Dec 4th, 2016
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 4.07 KB | None | 0 0
  1. // la boite du gobelin.cpp : définit le point d'entrée pour l'application console.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include "iostream"
  6. #include "time.h"
  7. #define MAX 5
  8. using namespace std;
  9.  
  10. int choix2(int [MAX][MAX], int [MAX][MAX], int cible);
  11. void initialiseTableau(int tableau[MAX][MAX], bool utiliseCompteur);
  12. void afficheTableau(int tableau[MAX][MAX]);
  13. void cache(int tableauCache[MAX][MAX]);
  14.  
  15. void main()
  16. {
  17.     time_t seconds;
  18.     time(&seconds);
  19.     srand((unsigned int)seconds);
  20.  
  21.     int chiffreExiste;
  22.     int tableauChiffre[MAX][MAX];
  23.     int tableauCache[MAX][MAX];
  24.     int cibleTir;
  25.     int essai = 3;
  26.     int choix;
  27.  
  28.  
  29.     system("cls");
  30.     cout << "apres un combat ereintant" << endl;
  31.     cout << "vous vous assoyez pres du cadavre du gobelin" << endl;
  32.     cout << "vous appercevez son sac" << endl;
  33.     cout << "en fouillant dedans vous trouvez une boites mystérieuse" << endl;
  34.     cout << "elle est ornée d'une série de nombres ainsi que de trois runes émettant une lumiere bleu" << endl;
  35.  
  36.     system("pause");
  37.     system("cls");
  38.  
  39.  
  40.     do
  41.     {
  42.        
  43.         if (essai > 0)
  44.         {
  45.             system("cls");
  46.             cout << "les runes emettent de la lumiere";
  47.             if (essai == 3)
  48.             {
  49.                 cout << " | | | " << endl;
  50.             }
  51.             if (essai == 2)
  52.             {
  53.                 cout << " | | " << endl;
  54.             }
  55.             if (essai == 1)
  56.             {
  57.                 cout << " | " << endl;
  58.             }
  59.    
  60.             afficheTableau(tableauChiffre);
  61.    
  62.         cout << "sur quel nombre appuyez vous" << endl;
  63.             cin >> cibleTir;
  64.             choix = choix2(tableauChiffre, tableauCache, cibleTir);
  65.    
  66.             system("cls");
  67.    
  68.             if (choix = 1)
  69.             {
  70.                 cout << "la boite s'ouvre laissant voir un anneau verdatre" << endl;
  71.                 cout << "en mettant cer anneau au doight, vous redevenez vous-même" << endl;
  72.                 cout << "en repensant au gobelin, vous remarquex qur vos mains prennent ne teinte verdatre" << endl;
  73.                 cout << "pris de panique, vous repensez a vos belle mains roses et elles reprennent leur forme" << endl;
  74.                 cout << "on dirait bien que vous avez trouver un anneau de transformation en gobelin" << endl;
  75.                 cout << "petit veinard" << endl;
  76.             }
  77.             else if (choix = 0)
  78.             {
  79.                 if (essai == 3)
  80.                 {
  81.                     cout << "votre peau devient verdatre" << endl;
  82.                 }
  83.                 else if (essai == 2)
  84.                 {
  85.                     cout << "vos oreilles se transforment en longues oreilles pendante" << endl;
  86.                     cout << "et des crocs appareissent dans votre bouche" << endl;
  87.                 }
  88.                 else if (essai == 1)
  89.                 {
  90.                     cout << "vous finalissez votre transformation en gobelin" << endl;
  91.                     cout << "vos instincts de gobelin prennent le dessus et vous vous cachez" << endl;
  92.                     cout << "ainsi prend fin votre aventure" << endl;
  93.                 }
  94.                 essai--;
  95.             }
  96.             else
  97.    
  98.                 cout << "mauvais nombre, reessayez" << endl;
  99.             system("pause");
  100.         }
  101.         system("pause");
  102.         main();
  103.     }
  104.     while (essai > 0);
  105.  
  106.     system("pause");
  107. }
  108.  
  109. int choix2(int tableauChiffre[MAX][MAX], int tableauCache[MAX][MAX], int cible)
  110. {
  111.     bool chiffreExiste;
  112.     chiffreExiste = false;
  113.     for (int x = 0; x < MAX; x++)
  114.     {
  115.         for (int y = 0; y < MAX; y++)
  116.         {
  117.             if (tableau[x][y] == cible)
  118.             {
  119.                 chiffreExiste = true;
  120.                     tableau[x][y] = 0;
  121.                 if (tableauCache[x][y] == 1)
  122.                 return 1;
  123.             }
  124.         }
  125.     }
  126.     if (chiffreExiste == false)
  127.     {
  128.         return -1;
  129.     }
  130.     else
  131.     {
  132.         return 0;
  133.     }
  134. }
  135.  
  136. void cache(int tableauCache[MAX][MAX])
  137. {
  138.     int randX;
  139.     int randY;
  140.  
  141.  
  142.     randX = rand() % MAX;
  143.     randY = rand() % MAX;
  144.  
  145.     tableau[randX][randY] = 1;
  146. }
  147.  
  148. void initialiseTableau(int tableau[MAX][MAX], bool utiliseCompteur)
  149. {
  150.     int compteur, valeurInitialisation;
  151.         compteur = 1;
  152.         valeurInitialisation = 0;
  153.  
  154.         for (int x = 0; x < MAX; x++)
  155.         {
  156.             for (int y = 0; y < MAX; y++)
  157.             {
  158.                 if (utiliseCompteur == false)
  159.                 {
  160.                     tableau[x][y] = valeurInitialisation;
  161.                 }
  162.                 else
  163.                 {
  164.                     tableau[x][y] = compteur;
  165.                     compteur++;
  166.                 }
  167.             }
  168.         }
  169. }
  170.  
  171. void afficheTableau(int tableau[MAX][MAX])
  172. {
  173.     for (int x = 0; x < MAX; x++)
  174.     {
  175.         for (int y = 0; y < MAX; y++)
  176.         {
  177.             if (tableau[x][y] == 0)
  178.             {
  179.                 cout << "   ";
  180.             }
  181.             else
  182.             {
  183.                 if (tableau[x][y] < 10)
  184.                 {
  185.                     cout << " ";
  186.                 }
  187.                     cout << tableau[x][y];
  188.                     cout << " ";
  189.             }
  190.         }
  191.     }
  192. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement