Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <fstream>
- #include <cmath>
- #include <vector>
- #include <algorithm>
- #include <cstdio>
- #include <math.h>
- #include <string>
- #include <stdio.h>
- #include <string.h>
- #include <string>
- #include <stdlib.h>
- #include <cmath>
- #include <iomanip>
- #include <queue>
- #include <utility>
- #include <vector>
- #include <stack>
- #include <list>
- #include <iterator>
- #include <cstdlib>
- #include <time.h>
- #include <stdlib.h>
- #include <cstdlib>
- using namespace std;
- int main(int argc, const char * argv[]) {
- cout<<"Welcome to game 'Rock,Scissors,Paper'"<<endl;
- int playAgain;
- bool check = true;
- int f;
- while (check==true){
- srand(time(0));
- cout<<"Do you want to..."<<endl;
- cout<<"1.play"<<endl;
- cout<<"2.read the rules"<<endl;
- cin>>f;
- if (f==1){
- int x;
- cout<<"Select the game mode"<<endl;
- cout<<"1.Single"<<endl;
- cout<<"2.For two players"<<endl;
- cin>>x;
- if (x==2){
- string a,b;
- cout<<"First player's choice(rock,paper,scissors)"<<endl;
- cin>>a;
- cout<<"Second player's choice(rock,paper,scissors)"<<endl;
- cin>>b;
- if (a.compare("scissors") == 0 ) {
- if (b.compare("rock") == 0 ) {
- cout<<"rock wins"<<endl;
- }
- if (b.compare("paper") == 0 ) {
- cout<<"scissors wins"<< endl;
- }
- if(b.compare("scissors") == 0){
- cout<<"draw"<<endl;
- }
- }
- if (a.compare("rock") == 0 ) {
- if (b.compare("paper") == 0 ) {
- cout<<"paper wins"<<endl;
- }
- if (b.compare("scissors") == 0 ) {
- cout<<"rock wins"<< endl;
- }
- if (b.compare("rock") == 0){
- cout<<"draw"<<endl;
- }
- }
- if (a.compare("paper") == 0 ) {
- if (b.compare("scissors") == 0 ) {
- cout<<"scissors wins"<<endl;
- }
- if (b.compare("rock") == 0 ) {
- cout<<"paper wins"<< endl;
- }
- if (b.compare("paper") == 0 ){
- cout<<"draw"<<endl;
- }
- }
- }
- if (x==1){
- int d;
- string a,b;
- cout<<"Your choice(rock,paper,scissors)"<<endl;
- cin>>a;
- d = rand() % 3 + 1;
- if(d==1){
- b="scissors";
- }
- if(d==2){
- b="rock";
- }
- else{
- b="paper";
- }
- cout<<"Computer's choice(rock,paper,scissors)"<<endl;
- cout<<b<<endl;
- if (a.compare("scissors") == 0 ) {
- if (b.compare("rock") == 0 ) {
- cout<<"Computer wins"<<endl;
- }
- if (b.compare("paper") == 0 ) {
- cout<<"You win"<< endl;
- }
- if(b.compare("scissors") == 0){
- cout<<"Draw"<<endl;
- }
- }
- if (a.compare("rock") == 0 ) {
- if (b.compare("paper") == 0 ) {
- cout<<"Computer wins"<<endl;
- }
- if (b.compare("scissors") == 0 ) {
- cout<<"You win"<< endl;
- }
- if (b.compare("rock") == 0){
- cout<<"Draw"<<endl;
- }
- }
- if (a.compare("paper") == 0 ) {
- if (b.compare("scissors") == 0 ) {
- cout<<"Computer wins"<<endl;
- }
- if (b.compare("rock") == 0 ) {
- cout<<"You win"<< endl;
- }
- if (b.compare("paper") == 0 ){
- cout<<"Draw"<<endl;
- }
- }
- }
- }
- if (f==2){
- cout<<"Rock crushes scissors, 1scissors cuts paper, and paper covers rock. There are NO exceptions."<<endl;;
- }
- cout<<"1.Play Again"<<endl;
- cout<<"2.Exit"<<endl;
- cin>>playAgain;
- if (playAgain==2){
- check=false;
- }
- if(playAgain==1){
- check=true;
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement