Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2017
78
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1. // Zaria.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include "stdafx.h"
  5. #include <iostream>
  6. #include <math.h>
  7. using namespace std;
  8.  
  9.  
  10. int main()
  11. {
  12.     srand(0);
  13.  
  14.     int money = 50;
  15.     int bet = 0;
  16.  
  17.     int firstcheat = 20;
  18.     int cheat = 5;
  19.  
  20.     for (;;)
  21.     {
  22.         cout << "You have: " << money << " euros" << endl;
  23.         cout << "How much do you want to bet?";
  24.         cin >> bet;
  25.         if (bet > money)
  26.         {
  27.             cout << "You dont have that much!" << endl;
  28.         }
  29.         else
  30.         {
  31.             int dice1 = 0;
  32.             int dice2 = 0;
  33.  
  34.             for (;;)
  35.             {
  36.                 dice1 = (rand() % 6) + 1;
  37.                 dice2 = (rand() % 6) + 1;
  38.                 if ((firstcheat % 4) == 0)
  39.                 {
  40.                     dice1 = 5;
  41.                     dice2 = 6;
  42.                 }
  43.                 firstcheat--;
  44.                 cheat--;
  45.                 if (cheat == 0)
  46.                 {
  47.                     dice1 = 1;
  48.                     dice2 = 2;
  49.                     cheat = 5;
  50.                 }
  51.  
  52.                 cout << "You have thrown: " << dice1 << " " << dice2 << endl;
  53.  
  54.                 if ((dice1 == 6 && dice2 == 6) || (dice1 == 6 && dice2 == 5) || (dice1 == 5 && dice2 == 6) || (dice1 == 3 && dice2 == 3) || (dice1 == 5 && dice2 == 5))
  55.                 {
  56.                     cout << " you won!" << endl;
  57.                     money = money + bet;
  58.                     break;
  59.                 }
  60.                 else
  61.                 {
  62.                     if ((dice1 == 1 && dice2 == 1) || (dice1 == 1 && dice2 == 2) || (dice1 == 2 && dice2 == 1) || (dice1 == 4 && dice2 == 4) || (dice1 == 2 && dice2 == 2))
  63.                     {
  64.                         cout << " you lost" << endl;
  65.                         money = money - bet;
  66.                         break;
  67.                     }
  68.                 }
  69.             }
  70.         }
  71.  
  72.         if (money == 0)
  73.         {
  74.             cout << "You are tapi!! Game over!" << endl;
  75.             break;
  76.         }
  77.  
  78.     }
  79.  
  80.     system("pause");
  81. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement