Guest User

Untitled

a guest
Dec 15th, 2018
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.09 KB | None | 0 0
  1. #include <iostream>
  2. #include <ctime>
  3. using namespace std;
  4.  
  5. int main()
  6. {
  7.  int CORDX,CORDY;
  8.  CORDX = 0;
  9.  CORDY = 0;
  10.  int Plansza[5][5];
  11.  srand(time(NULL));
  12.  int position;
  13.  
  14.  /*Inicjalizacja planszy */
  15.  for(int i = 0; i < 5; i++)
  16.  {
  17.   for(int j = 0; j < 5; j++)
  18.   {
  19.     position = 1 + rand()%4;
  20.     Plansza[i][j] = position;
  21.   }        
  22.  }
  23.  
  24.  /*Wyświetlanie planszy*/
  25.   for(int i = 0; i < 5; i++)
  26.  {
  27.   for(int j = 0; j < 5; j++)
  28.   {
  29.    
  30.      cout <<   Plansza[i][j];
  31.      cout << " ";
  32.      if(j==4) { cout << "|" << endl;}
  33.   }        
  34.  }
  35.  
  36.  cout << "- - - - - - ";
  37.  cout << endl;
  38.  
  39.   int bomba_one;
  40.   int bomba_two;
  41.  
  42.      
  43.  
  44.  
  45.  cout << "Set coordination: " << endl;
  46.  while(true)
  47.  {
  48.  bomba_one = 1 + rand()%4 + 0;
  49.  bomba_two = 1 + rand()%4 + 0;
  50.  cout << "bomb: " << "[" << bomba_one << ", " << bomba_two << "]"<< endl;
  51.  cout << "CORDX: ";
  52.  cin >> CORDX;
  53.  cout << "CORDY: ";
  54.  cin >> CORDY;
  55.  
  56.  if( (CORDX==bomba_one) && (CORDY == bomba_two)   )
  57.  cout << "buuum" << endl;
  58.  else
  59.  cout << "Masz punkty!" << endl;
  60.  
  61. }
  62.  
  63.    
  64.  cin.ignore();
  65.  cin.get();
  66.  return 0;  
  67. }
Add Comment
Please, Sign In to add comment