Advertisement
Guest User

Untitled

a guest
Feb 22nd, 2018
75
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.02 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstdlib>
  3. #include <ctime>
  4. using namespace std;
  5. int main (){
  6.  
  7. srand(time(0));
  8.  
  9. string a[]={"Rock","Paper","Scissors"};
  10.  
  11. string c=a[rand()%(sizeof(a)/sizeof(a[0]))];
  12.  
  13.  
  14. string b;
  15.  
  16. cout<<"Rock,Paper or Scissors?"<<endl;
  17. cin>>b;
  18. cout<<"Computer chose: "<<c<<endl;
  19.  
  20.  
  21. if (b=="Rock" || b=="rock" && c=="Rock")
  22. {
  23. cout<<"It's a tie!";
  24. }
  25.  
  26. else if (b=="Rock" || b=="rock" && c=="Paper")
  27. {
  28. cout<<"You lose!";
  29. }
  30.  
  31. else if (b=="Rock" || b=="rock" && c=="Scissors")
  32. {
  33. cout<<"You win!";
  34. }
  35.  
  36.  if (b=="Paper" || b=="paper" && c=="Rock")
  37. {
  38. cout<<"You win!";
  39. }
  40.  
  41. else if (b=="Paper" || b=="paper" && c=="Paper")
  42. {
  43. cout<<"It's a tie!";
  44. }
  45.  
  46. else if (b=="Paper" || b=="paper" && c=="Scissors")
  47. {
  48. cout<<"You lose!";
  49. }
  50.  
  51.  if (b=="Scissors" || b=="scissors" && c=="Rock")
  52. {
  53. cout<<"You lose!";
  54. }
  55.  
  56. else if (b=="Scissors" || b=="scissors" && c=="Paper")
  57. {
  58. cout<<"You win!";
  59. }
  60.  
  61. else if (b=="Scissors" || b=="scissors" && c=="Scissors")
  62. {
  63. cout<<"It's a tie!";
  64. }
  65.  
  66.  
  67.  
  68.     return 0;
  69. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement