Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- void menu()
- {
- system("cls");
- }
- int main()
- {
- cout << "Welcome to 5-10 game!" << endl << "In this game, you can add 5 or 10 to the previous number."<<endl<<"Your target is to reach 100 first. The game always starts with 0."<<endl<<"For example, if you are provided with 50, in this case you can jump to 55 or 60. From 15, you can jump to 20 or 25."<<endl<<"Hope you enjoy the game! Best of luck"<<endl<<endl;
- int game;
- cout << "Press 1 to enter the game : ";
- cin >> game;
- menu();
- cout << "Press 1 for single player / ";
- cout << "Press 2 for multiplayers : ";
- int game_players;
- cin >> game_players;
- menu();
- if(game_players == 1)
- {
- cout << "Open first? Y/N : ";
- char opening;
- cin >> opening;
- menu();
- if(opening=='Y')
- {
- int x,y=0;
- while(1)
- {
- cout<<"You: ";
- cin >> x;
- if(x==y+5 || x==y+10)
- {
- if(x==5)
- {
- y=10;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==10)
- {
- y=15;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==15)
- {
- y=20;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==20)
- {
- y=30;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==25)
- {
- y=30;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==30)
- {
- y=40;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==35)
- {
- y=40;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==40)
- {
- y=45;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==45)
- {
- y=55;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==50)
- {
- y=55;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==55)
- {
- y=60;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==60)
- {
- y=70;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==65)
- {
- y=70;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==70)
- {
- y=75;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==75)
- {
- y=85;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==80)
- {
- y=85;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==85)
- {
- y=90;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==90)
- {
- y=100;
- cout<<"CPU: "<<y<<endl;
- cout<<"Sorry! You lose"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- if(x==95)
- {
- y=100;
- cout<<"CPU: "<<y<<endl;
- cout<<"Sorry! You lose"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- if(x==100)
- {
- cout<<"Congratulations! You win"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- else
- {
- cout << "Wrong Input. Bye"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- }
- else
- {
- int x,y=10;
- cout<<"CPU: "<<y<<endl;
- while(1)
- {
- cout<<"You: ";
- cin>>x;
- if(x==y+5 || x==y+10)
- {
- if(x==15)
- {
- y=20;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==20)
- {
- y=25;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==25)
- {
- y=30;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==30)
- {
- y=40;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==35)
- {
- y=40;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==40)
- {
- y=45;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==45)
- {
- y=55;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==50)
- {
- y=55;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==55)
- {
- y=60;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==60)
- {
- y=70;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==65)
- {
- y=70;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==70)
- {
- y=75;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==75)
- {
- y=85;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==80)
- {
- y=85;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==85)
- {
- y=90;
- cout<<"CPU: "<<y<<endl;
- }
- if(x==90)
- {
- y=100;
- cout<<"CPU: "<<y<<endl;
- cout<<"Sorry! You lose"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- if(x==95)
- {
- y=100;
- cout<<"CPU: "<<y<<endl;
- cout<<"Sorry! You lose"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- if(x==100)
- {
- cout<<"Congratulations! You win"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- else
- {
- cout << "Wrong Input. Bye"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- }
- }
- else
- {
- char player1[100],player2[100];
- cout<<"Enter the first name of player 1 : ";
- scanf("%s",player1);
- cout<<"Enter the first name of player 2 : ";
- scanf("%s",player2);
- int x=0,y=0;
- printf("Who want to move first? Player 1(Press 1) or Player 2(Press 2) : ");
- int first_move;
- cin >> first_move;
- menu();
- for(int i=1 ; ; i++)
- {
- if(i%2!=0 && first_move==1)
- {
- printf("turn of %s : ",player1);
- cin>>x;
- if(x==y+5 || x==y+10)
- {
- if(x==100)
- {
- printf("%s wins\n",player1);
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- else
- {
- cout << "Wrong Input. Bye"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- else if(i%2==0 && first_move==1)
- {
- printf("turn of %s : ",player2);
- cin>>y;
- if(y==x+5 || y==x+10)
- {
- if(y==100)
- {
- printf("%s wins\n",player2);
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- else
- {
- cout << "Wrong Input. Bye"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- if(i%2!=0 && first_move==2)
- {
- printf("turn of %s : ",player2);
- cin>>x;
- if(x==y+5 || x==y+10)
- {
- if(x==100)
- {
- printf("%s wins\n",player2);
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- else
- {
- cout << "Wong Input. Bye"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- else if(i%2==0 && first_move==2)
- {
- printf("turn of %s : ",player1);
- cin>>y;
- if(y==x+5 || y==x+10)
- {
- if(y==100)
- {
- printf("%s wins\n",player1);
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- else {
- cout << "Wrong Input. Bye"<<endl;
- cout<<"Press 0 to exit the game ";
- int exit;
- cin>>exit;
- if(exit==0) return 0;
- }
- }
- }
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement