Advertisement
Guest User

Untitled

a guest
Oct 14th, 2019
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.83 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <time.h>
  4. #include <iomanip>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10. srand(time(0));
  11. bool a1=0;
  12. bool a6=0;
  13. bool b1=0;
  14. bool b6=0;
  15. bool c1=0;
  16. bool c6=0;
  17. bool d1=0;
  18. bool d6=0;
  19. bool koniec=0;
  20. int A=0;
  21. int B=0;
  22. int C=0;
  23. int D=0;
  24. int X, a, b, c, d;
  25. cout<<"Podaj wielkosc pola gry: ";
  26. cin>>X;
  27. while(koniec!=1)
  28. {
  29. a=rand()%6+1;
  30. b=rand()%6+1;
  31. c=rand()%6+1;
  32. d=rand()%6+1;
  33. if(a1==1&&a6==1)
  34. {
  35. A+=a;
  36. }
  37. else if(a==1)
  38. {
  39. a1=1;
  40. }
  41. else if(a1==1&&a==6)
  42. {
  43. a6=1;
  44. }
  45. else
  46. {
  47. a1=0;
  48. a6=0;
  49. }
  50. if(b1==1&&b6==1)
  51. {
  52. B+=b;
  53. }
  54. else if(b==1)
  55. {
  56. b1=1;
  57. }
  58. else if(b1==1&&b==6)
  59. {
  60. b6=1;
  61. }
  62. else
  63. {
  64. b1=0;
  65. b6=0;
  66. }
  67. if(c1==1&&c6==1)
  68. {
  69. C+=c;
  70. }
  71. else if(c==1)
  72. {
  73. c1=1;
  74. }
  75. else if(c1==1&&c==6)
  76. {
  77. c6=1;
  78. }
  79. else
  80. {
  81. c1=0;
  82. c6=0;
  83. }
  84. if(d1==1&&d6==1)
  85. {
  86. D+=d;
  87. }
  88. else if(d==1)
  89. {
  90. d1=1;
  91. }
  92. else if(d1==1&&d==6)
  93. {
  94. d6=1;
  95. }
  96. else
  97. {
  98. d1=0;
  99. d6=0;
  100. }
  101. cout<<setw(3)<<" < "<<a<<" "<<b<<" "<<c<<" "<<d<<endl;
  102. cout<<setw(3)<<" P "<<A<<" "<<B<<" "<<C<<" "<<D<<endl;
  103. if(A>X||B>X||C>X||D>X)
  104. {
  105. koniec=1;
  106. }
  107. }
  108. return 0;
  109. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement