Advertisement
Marcel12311

C++ game console#2

Apr 13th, 2021
246
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.06 KB | None | 0 0
  1. #include <iostream>
  2. #include <time.h>
  3. #include <windows.h>
  4. #include <conio.h>
  5. using namespace std;
  6. int main()
  7. {
  8.     srand(time(NULL));
  9.     int tab[10];
  10.     int number=0;
  11.     int number2=0;
  12.     int xx=0;
  13.     char www;
  14.     bool bol=false;
  15.     while(bol != true)
  16.     {
  17.         int z = 0;
  18.         system("cls");
  19.         for(int i=1; i<=10; i++)
  20.         {
  21.             tab[i]=i;
  22.             number=rand()%10+1;
  23.             number2=rand()%6;
  24.             if(i%number==number2)
  25.             {
  26.                 cout<<"["<<tab[i]<<"] ";
  27.                 z += tab[i];
  28.             }
  29.             else
  30.                 cout << tab[i]<<" ";
  31.  
  32.         }
  33.         xx+=z;
  34.         cout <<endl<<"hits: "<<z<<"|||Your points: "<<xx;
  35.         cout << "\nprint any key to Continue...";
  36.         Sleep(100);
  37.         www=getch();
  38.         cout << www;
  39.         if(xx >= 1000)
  40.         {
  41.             bol=true;
  42.         }
  43.     }
  44.     if(bol == true)
  45.     {
  46.         system("cls");
  47.         cout << "YOU WINNER!\n";
  48.         cout << "YOUR SCORE: "<<xx<<endl;
  49.     }
  50.     return 0;
  51. }
  52.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement