Advertisement
askarulytarlan

Untitled

Apr 20th, 2016
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 3.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <cmath>
  4. #include <vector>
  5. #include <algorithm>
  6. #include <cstdio>
  7. #include <math.h>
  8. #include <string>
  9. #include <stdio.h>
  10. #include <string.h>
  11. #include <string>
  12. #include <stdlib.h>
  13. #include <cmath>
  14. #include <iomanip>
  15. #include <queue>
  16. #include <utility>
  17. #include <vector>
  18. #include <stack>
  19. #include <list>
  20. #include <iterator>
  21. #include <cstdlib>
  22. #include <time.h>
  23. #include <stdlib.h>
  24. #include <cstdlib>
  25.  
  26. using namespace std;
  27.  
  28. int main(int argc, const char * argv[]) {
  29. cout<<"Welcome to game 'Rock,Scissors,Paper'"<<endl;
  30. int playAgain;
  31. bool check = true;
  32. int f;
  33. while (check==true){
  34. srand(time(0));
  35. cout<<"Do you want to..."<<endl;
  36. cout<<"1.play"<<endl;
  37. cout<<"2.read the rules"<<endl;
  38. cin>>f;
  39. if (f==1){
  40. int x;
  41. cout<<"Select the game mode"<<endl;
  42. cout<<"1.Single"<<endl;
  43. cout<<"2.For two players"<<endl;
  44. cin>>x;
  45. if (x==2){
  46. string a,b;
  47. cout<<"First player's choice(rock,paper,scissors)"<<endl;
  48. cin>>a;
  49. cout<<"Second player's choice(rock,paper,scissors)"<<endl;
  50. cin>>b;
  51. if (a.compare("scissors") == 0 ) {
  52. if (b.compare("rock") == 0 ) {
  53. cout<<"rock wins"<<endl;
  54. }
  55. if (b.compare("paper") == 0 ) {
  56. cout<<"scissors wins"<< endl;
  57. }
  58. if(b.compare("scissors") == 0){
  59. cout<<"draw"<<endl;
  60. }
  61. }
  62. if (a.compare("rock") == 0 ) {
  63. if (b.compare("paper") == 0 ) {
  64. cout<<"paper wins"<<endl;
  65. }
  66. if (b.compare("scissors") == 0 ) {
  67. cout<<"rock wins"<< endl;
  68. }
  69. if (b.compare("rock") == 0){
  70. cout<<"draw"<<endl;
  71. }
  72. }
  73. if (a.compare("paper") == 0 ) {
  74. if (b.compare("scissors") == 0 ) {
  75. cout<<"scissors wins"<<endl;
  76. }
  77. if (b.compare("rock") == 0 ) {
  78. cout<<"paper wins"<< endl;
  79. }
  80. if (b.compare("paper") == 0 ){
  81. cout<<"draw"<<endl;
  82. }
  83. }
  84. }
  85. if (x==1){
  86. int d;
  87. string a,b;
  88. cout<<"Your choice(rock,paper,scissors)"<<endl;
  89. cin>>a;
  90.  
  91. d = rand() % 3 + 1;
  92. if(d==1){
  93. b="scissors";
  94. }
  95. if(d==2){
  96. b="rock";
  97. }
  98. else{
  99. b="paper";
  100. }
  101. cout<<"Computer's choice(rock,paper,scissors)"<<endl;
  102. cout<<b<<endl;
  103. if (a.compare("scissors") == 0 ) {
  104. if (b.compare("rock") == 0 ) {
  105. cout<<"Computer wins"<<endl;
  106. }
  107. if (b.compare("paper") == 0 ) {
  108. cout<<"You win"<< endl;
  109. }
  110. if(b.compare("scissors") == 0){
  111. cout<<"Draw"<<endl;
  112. }
  113. }
  114. if (a.compare("rock") == 0 ) {
  115. if (b.compare("paper") == 0 ) {
  116. cout<<"Computer wins"<<endl;
  117. }
  118. if (b.compare("scissors") == 0 ) {
  119. cout<<"You win"<< endl;
  120. }
  121. if (b.compare("rock") == 0){
  122. cout<<"Draw"<<endl;
  123. }
  124. }
  125. if (a.compare("paper") == 0 ) {
  126. if (b.compare("scissors") == 0 ) {
  127. cout<<"Computer wins"<<endl;
  128. }
  129. if (b.compare("rock") == 0 ) {
  130. cout<<"You win"<< endl;
  131. }
  132. if (b.compare("paper") == 0 ){
  133. cout<<"Draw"<<endl;
  134. }
  135. }
  136. }
  137. }
  138. if (f==2){
  139. cout<<"Rock crushes scissors, 1scissors cuts paper, and paper covers rock. There are NO exceptions."<<endl;;
  140. }
  141. cout<<"1.Play Again"<<endl;
  142. cout<<"2.Exit"<<endl;
  143. cin>>playAgain;
  144. if (playAgain==2){
  145. check=false;
  146. }
  147. if(playAgain==1){
  148. check=true;
  149. }
  150. }
  151.  
  152. return 0;
  153. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement