Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.94 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3.  
  4. using namespace std;
  5.  
  6. int Tura();
  7. int Points;
  8.  
  9. int main()
  10. {
  11. srand(time(NULL));
  12. int First = 0;
  13. int ScoreFirst = 0;
  14. int Second = 0;
  15. int ScoreSecond = 0;
  16.  
  17. for (int j = 1; j <= 5; j++)
  18. {
  19. cout << "Tura " << j <<endl;
  20.  
  21. cout << "Gracz pierwszy\n";
  22.  
  23. First = Tura();
  24.  
  25. cout << "\n Liczba punktow dla gracza 1 = " << First << "\n";
  26.  
  27. ScoreFirst += First;
  28.  
  29. cout << "Gracz Drugi\n";
  30.  
  31. Second = Tura();
  32.  
  33. cout << "\n Liczba punktow dla gracza 2 = " << Second << "\n";
  34. ScoreSecond += Second;
  35.  
  36. cout << "Koniec " << j << " tury"<<endl;
  37. }
  38. cout << "\n Wynik gracza 1 = " << ScoreFirst;
  39. cout << "\n Wynik gracza 2 = " << ScoreSecond;
  40. if (ScoreFirst < ScoreSecond)
  41. {
  42. cout << "\n Wygrywa pierwszy zawodnik";
  43. }
  44. else if (ScoreFirst > ScoreSecond)
  45. {
  46. cout << "\n Wygrywa drugi zawodnik";
  47. }
  48. else
  49. {
  50. cout << "\n REMIS!";
  51. }
  52.  
  53. return 0;
  54. }
  55.  
  56. int Tura()
  57. {
  58.  
  59. int Dice1, Dice2;
  60. for (int i = 1; i <= 10; i++)
  61. {
  62. Dice1 = rand() % 6 + 1;
  63. Dice2 = rand() % 6 + 1;
  64. int SumPoints = Dice1 + Dice2;
  65. cout << Dice1 << " + " << Dice2 << " = " << SumPoints << "\n\n";
  66.  
  67. if (i == 1 and SumPoints == 7)
  68. {
  69. Points = 0;
  70. break;
  71. }
  72. else if (i == 1 and SumPoints == 11)
  73. {
  74. Points = 0;
  75. break;
  76. }
  77. else if (i == 1 and SumPoints == 2)
  78. {
  79. Points = 12 / i;
  80. break;
  81. }
  82. else if (i == 1 and SumPoints == 12)
  83. {
  84. Points = 12 / i;
  85. break;
  86. }
  87. else if (SumPoints == 5)
  88. {
  89. break;
  90. }
  91. else
  92. {
  93. Points += SumPoints / i;
  94. }
  95. }
  96. return Points;
  97. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement