Advertisement
Guest User

gra

a guest
Oct 20th, 2017
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.20 KB | None | 0 0
  1. // Laborka.cpp : Defines the entry point for the console application.
  2. //
  3.  
  4. #include <iostream>
  5. using namespace std;
  6. #define liczba_graczy 4
  7. int main()
  8. {
  9.     int X;
  10.     char litera;
  11.     int wartosc,koniec;
  12.     cin >> X;
  13.     int G[liczba_graczy];
  14.     int Poprzedni_ruch[liczba_graczy];
  15.     bool Start[liczba_graczy];
  16.     for (int i = 0; i < liczba_graczy; i++) {
  17.         G[i] = 0;
  18.         Start[i] = false;
  19.         Poprzedni_ruch[i] = 0;
  20.     }
  21.     koniec = 1;
  22.     while (koniec != 0) {
  23.         for (int h = 0; h < liczba_graczy; h++) {
  24.             cout << "*" << h << "*" << endl;
  25.             litera = NULL;
  26.             cin >> litera;
  27.             if (litera == 'M') {
  28.                 cin >> wartosc;
  29.                 if (wartosc < 1 || wartosc >6)
  30.                 {
  31.                     cout << "Twoja wartosc jest za duza albo za mała.Podaj jeszcze raz wartosc oczek od 1-6";
  32.                     cin >> wartosc;
  33.                 }
  34.  
  35.                 if (Start[h] == false) {
  36.                     if (Poprzedni_ruch[h] == 1 && wartosc == 6) {
  37.                         Start[h] = true;
  38.                     }
  39.                 }
  40.                 else {
  41.                     if(G[h]+wartosc <= X)
  42.                         G[h] += wartosc;
  43.                
  44.                 }
  45.             }
  46.             else
  47.             {
  48.                 for (int i = 0; i < liczba_graczy; i++) {
  49.                     cout << "G" << i + 1 << " punty: " << G[i] << endl;
  50.                 }
  51.                 h--;
  52.             }
  53.             if (G[h] >= X)
  54.                 koniec = 0;
  55.         }
  56.     }
  57.     cout << "END OF GAME";
  58.     return 0;
  59. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement