Advertisement
xDefo

Dadi

Apr 10th, 2017
205
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 2.08 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <time.h>
  4. #include <stdlib.h>
  5.  
  6. using namespace std;
  7.  
  8. vector < int> chip;
  9. int dadi [3];
  10.  
  11. void tiroDadi()
  12. {
  13.     srand (time(NULL));
  14.     for(int i=0; i<2;i++)
  15.         {
  16.             dadi[i]=rand()%6+1;
  17.         }
  18.     dadi[3]=dadi[1]+dadi[2];
  19. }
  20.  
  21. void vincita(int quantita)
  22. {
  23.     for(int i =0;i<quantita*2;i++)
  24.         {
  25.             chip.push_back(1);
  26.         }
  27. }
  28.  
  29. int main() {
  30.     int temp;
  31.     int puntata;
  32.     bool verifica =true;
  33.     bool verifica1 =true;
  34.     string sno ="";
  35.      cout<<"Inserire budget: ";
  36.     cin>>temp;
  37.     chip.resize(temp,1);
  38.     while(verifica1)
  39.     {
  40.         verifica1=false;
  41.         cout<<"Inserire puntata: ";
  42.         cin>>puntata;
  43.         for(int i=0;i<puntata;i++)
  44.             {
  45.                 chip.pop_back();
  46.             }
  47.         if(chip.size()<=0)
  48.         {
  49.             cout<<"Sei in rosso";
  50.             verifica = false;
  51.         }
  52.         if(verifica)
  53.             {
  54.                 tiroDadi();
  55.                 if(dadi[3]==1||dadi[3]==4||dadi[3]==5||dadi[3]==6||dadi[3]==8||dadi[3]==9||dadi[3]==10)
  56.                     {
  57.                         cout<<"Hai perso"<<endl;
  58.                     }
  59.                 else if(dadi[3]==7||dadi[3]==11)
  60.                     {
  61.                         cout<<"Hai vinto"<<endl;
  62.                         vincita(puntata);
  63.                     }
  64.                 else if (dadi[3]==2||dadi[3]==3||dadi[3]==12)
  65.                     {
  66.                         cout<<"Puoi ritirare!"<<endl;
  67.                     while(true)
  68.                         {
  69.                             tiroDadi();
  70.                             if(dadi[3]==2||dadi[3]==3||dadi[3]==12)
  71.                             {
  72.                                 cout<<"Hai vinto"<<endl;
  73.                                 vincita(puntata);
  74.                                 break;
  75.                             }
  76.                             else if(dadi[3]==7)
  77.                                 {
  78.                                     cout<<"Hai perso"<<endl;
  79.                                     break;
  80.                                 }
  81.                         }
  82.                     }
  83.             }
  84.         cout << "Il tuo budget ora e di: "<<chip.size()<<endl;
  85.         cout<<"Vuoi continuare a rischiare?Inserisci Si per continuare, No per uscire.";
  86.         cin>>sno;
  87.         if(sno=="Si")
  88.         {
  89.             verifica1 = true;
  90.         }
  91.         else if (sno=="No")
  92.         {
  93.             cout<<"Ciao";
  94.         }
  95.    
  96.     }
  97.     return 0;
  98. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement