Advertisement
codecstasy

5-10 Game

Sep 29th, 2020
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 6.33 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. void menu() {
  5.     system("cls");
  6. }
  7.  
  8. int main() {
  9.     cout << "Welcome to 5-10 game!" << endl << "In this game, you can add 5 or 10 to a specific number."<<endl<<"Your target is to reach 100 first. The game always starts with 0."<<endl<<"For example, you are provided with 50, in this case you can jump to 55 or 60."<<endl<<"Hope you enjoy the game! Best of luck"<<endl<<endl;
  10.     int game;
  11.     cout << "Press 1 to enter the game : ";
  12.     cin >> game;
  13.     menu();
  14.     cout << "Press 1 for single player / ";
  15.     cout << "Press 2 for multiplayers : ";
  16.     int game_players;
  17.     cin >> game_players;
  18.     menu();
  19.     if(game_players == 1) {
  20.         cout << "Open first? Y/N : ";
  21.         char opening;
  22.         cin >> opening;
  23.         menu();
  24.         if(opening=='Y') {
  25.            int x,y;
  26.            while(1) {
  27.             cin >> x;
  28.             if(x==5) {
  29.                 y=10;
  30.                 cout<<y<<endl;
  31.             }
  32.             if(x==10) {
  33.                 y=15;
  34.                 cout<<y<<endl;
  35.             }
  36.             if(x==15) {
  37.                 y=20;
  38.                 cout<<y<<endl;
  39.             }
  40.             if(x==20) {
  41.                 y=30;
  42.                 cout<<y<<endl;
  43.             }
  44.             if(x==25) {
  45.                 y=30;
  46.                 cout<<y<<endl;
  47.             }
  48.             if(x==30) {
  49.                 y=40;
  50.                 cout<<y<<endl;
  51.             }
  52.             if(x==35) {
  53.                 y=40;
  54.                 cout<<y<<endl;
  55.             }
  56.             if(x==40) {
  57.                 y=45;
  58.                 cout<<y<<endl;
  59.             }
  60.             if(x==45) {
  61.                 y=55;
  62.                 cout<<y<<endl;
  63.             }
  64.             if(x==50) {
  65.                 y=55;
  66.                 cout<<y<<endl;
  67.             }
  68.             if(x==55) {
  69.                 y=60;
  70.                 cout<<y<<endl;
  71.             }
  72.             if(x==60) {
  73.                 y=70;
  74.                 cout<<y<<endl;
  75.             }
  76.             if(x==65) {
  77.                 y=70;
  78.                 cout<<y<<endl;
  79.             }
  80.             if(x==70) {
  81.                 y=75;
  82.                 cout<<y<<endl;
  83.             }
  84.             if(x==75) {
  85.                 y=85;
  86.                 cout<<y<<endl;
  87.             }
  88.             if(x==80) {
  89.                 y=85;
  90.                 cout<<y<<endl;
  91.             }
  92.             if(x==85) {
  93.                 y=90;
  94.                 cout<<y<<endl;
  95.             }
  96.             if(x==90) {
  97.                 y=100;
  98.                 cout<<y<<endl;
  99.                 cout<<"Sorry! You lose"<<endl;
  100.                 break;
  101.             }
  102.             if(x==95) {
  103.                 y=100;
  104.                 cout<<y<<endl;
  105.                 cout<<"Sorry! You lose"<<endl;
  106.             }
  107.             if(x==100) {
  108.                 cout<<"Congratulations! You win"<<endl;
  109.                 break;
  110.             }
  111.            }
  112.         }
  113.         else {
  114.             int x,y=10;
  115.             cout<<y<<endl;
  116.             while(1) {
  117.             cin>>x;
  118.             if(x==15) {
  119.                 y=20;
  120.                 cout<<y<<endl;
  121.             }
  122.             if(x==20) {
  123.                 y=30;
  124.                 cout<<y<<endl;
  125.             }
  126.             if(x==25) {
  127.                 y=30;
  128.                 cout<<y<<endl;
  129.             }
  130.             if(x==30) {
  131.                 y=40;
  132.                 cout<<y<<endl;
  133.             }
  134.             if(x==35) {
  135.                 y=40;
  136.                 cout<<y<<endl;
  137.             }
  138.             if(x==40) {
  139.                 y=45;
  140.                 cout<<y<<endl;
  141.             }
  142.             if(x==45) {
  143.                 y=55;
  144.                 cout<<y<<endl;
  145.             }
  146.             if(x==50) {
  147.                 y=55;
  148.                 cout<<y<<endl;
  149.             }
  150.             if(x==55) {
  151.                 y=60;
  152.                 cout<<y<<endl;
  153.             }
  154.             if(x==60) {
  155.                 y=70;
  156.                 cout<<y<<endl;
  157.             }
  158.             if(x==65) {
  159.                 y=70;
  160.                 cout<<y<<endl;
  161.             }
  162.             if(x==70) {
  163.                 y=75;
  164.                 cout<<y<<endl;
  165.             }
  166.             if(x==75) {
  167.                 y=85;
  168.                 cout<<y<<endl;
  169.             }
  170.             if(x==80) {
  171.                 y=85;
  172.                 cout<<y<<endl;
  173.             }
  174.             if(x==85) {
  175.                 y=90;
  176.                 cout<<y<<endl;
  177.             }
  178.             if(x==90) {
  179.                 y=100;
  180.                 cout<<y<<endl;
  181.                 cout<<"Sorry! You lose"<<endl;
  182.                 break;
  183.             }
  184.             if(x==95) {
  185.                 y=100;
  186.                 cout<<y<<endl;
  187.                 cout<<"Sorry! You lose"<<endl;
  188.             }
  189.             if(x==100) {
  190.                 cout<<"Congratulations! You win"<<endl;
  191.                 break;
  192.             }
  193.           }
  194.         }
  195.     }
  196.     else {
  197.         char player1[100],player2[100];
  198.         cout<<"Enter the first name of player 1 : ";
  199.         scanf("%s",player1);
  200.         cout<<"Enter the first name of player 2 : ";
  201.         scanf("%s",player2);
  202.         int x,y;
  203.         printf("Who want to move first? Player 1(Press 1) or Player 2(Press 2) : ");
  204.         int first_move;
  205.         cin >> first_move;
  206.         menu();
  207.         for(int i=1 ; ; i++) {
  208.             if(i%2!=0 && first_move==1) {
  209.                 printf("turn of %s : ",player1);
  210.                 cin>>x;
  211.                 if(x==100) {
  212.                     printf("%s wins",player1);
  213.                     break;
  214.                 }
  215.             }
  216.             else if(i%2==0 && first_move==1) {
  217.                 printf("turn of %s : ",player2);
  218.                 cin>>y;
  219.                 if(y==100) {
  220.                     printf("%s wins",player2);
  221.                     break;
  222.                 }
  223.             }
  224.             if(i%2!=0 && first_move==2) {
  225.                 printf("turn of %s : ",player2);
  226.                 cin>>x;
  227.                 if(x==100) {
  228.                     printf("%s wins",player2);
  229.                     break;
  230.                 }
  231.             }
  232.             else if(i%2==0 && first_move==2){
  233.                 printf("turn of %s : ",player1);
  234.                 cin>>y;
  235.                 if(y==100) {
  236.                     printf("%s wins",player1);
  237.                     break;
  238.                 }
  239.             }
  240.         }
  241.     }
  242.     return 0;
  243. }
  244.  
  245.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement