Advertisement
Guest User

chuj

a guest
Oct 14th, 2019
92
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.96 KB | None | 0 0
  1. #include <iostream>
  2.  
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7. int X,liczba;
  8. int g[4], a[4], b[4], j = 0;
  9. cout << "Wielkosc pola:";
  10. cin >> X;
  11. for (j; j < 4; j++)
  12. {
  13. g[j] = 0;
  14. a[j] = 0;
  15. b[j] = 0;
  16. }
  17. j = 0;
  18. do
  19. {
  20. for (j; j < 4; j++)
  21. {
  22. cout << "Oczka gracza "<<j+1<<":";
  23. cin >> liczba;
  24. if (a[j] == 1 && b[j] == 6)
  25. {
  26. g[j] = g[j] + liczba;
  27. if (g[j] == X)
  28. {
  29. cout << "Koniec gry! Wygral gracz:" << j << endl;
  30. return 0;
  31. }
  32. else if (g[j] > X)
  33. {
  34. g[j] = g[j] - liczba;
  35. }
  36. }
  37. else if (a[j] == 1 && liczba==6 && b[j]==0)
  38. {
  39. b[j] = 6;
  40. }
  41. else if (liczba == 1 && a[j] == 0)
  42. {
  43. a[j] = 1;
  44. }
  45. else
  46. {
  47. a[j] = 0;
  48. b[j] = 0;
  49. }
  50. }
  51. j = 0;
  52. cout << "Pozycja gracza 1:" << g[0] << endl;
  53. cout << "Pozycja gracza 2:" << g[1] << endl;
  54. cout << "Pozycja gracza 3:" << g[2] << endl;
  55. cout << "Pozycja gracza 4:" << g[3] << endl;
  56. } while (g[j] != X);
  57. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement