midoking

paper/scissor/rocket

Jul 29th, 2017
291
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.13 KB | None | 0 0
  1. #include <iostream>
  2. #include<stdlib.h>
  3. #include<cmath>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int r = 0, s = 1, p = 2, n, size;
  9.     cout << "enter the size of tries" << endl;
  10.     cin >> size;
  11.     for (int i = 1; i <= size; i++) {
  12.         cout << "enter 0 for rock, 1 for Siccor, 2 for papaer" << endl;
  13.         cin >> n;
  14.         if (n == 0) {
  15.             if (rand() % 3 == 1)
  16.                 cout << "You're won, you choosed a Rock and computer choosed a scissor" << endl;
  17.             else if (rand() % 3 == 2)
  18.                 cout << "You're lost, you choosed a Rock and computer choosed a paper" << endl;
  19.         }
  20.         else if (n == 1) {
  21.             if (rand() % 3 == 2)
  22.                 cout << "You're won, you choosed a Scissor and computer choosed a paper" << endl;
  23.             else if (rand() % 3 == 0)
  24.                 cout << "You're lost, you choosed a Scissor and computer choosed a rock" << endl;
  25.         }
  26.         else if (n == 2) {
  27.             if (rand() % 3 == 0)
  28.                 cout << "You're won, you choosed a Paper and computer choosed a Rock" << endl;
  29.             else if (rand() % 3 == 1)
  30.                 cout << "You're lost, you choosed a Paper and computer choosed a Scissor" << endl;
  31.         }
  32.         else
  33.             cout << "Enter a right number" << endl;
  34.     }
  35.     system("pause");
  36.     return 0;
  37. }
Advertisement
Add Comment
Please, Sign In to add comment