Advertisement
Guest User

Untitled

a guest
Nov 17th, 2019
158
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.50 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <cstdio>
  4. #include <ctime>
  5. using namespace std;
  6. const int wielkosc_tab = 10;
  7.  
  8. class klasa {
  9. public:
  10.     char plansza[wielkosc_tab][wielkosc_tab];
  11.     int poziom;
  12.     int poziomplansza;
  13.  
  14. ////////////////////////////////////////////////////////wypisywanie tablicy
  15.     void wypisywanie()
  16.     {
  17.         system("cls");
  18.         cout << "   A B C D E F G H I J\n";
  19.         for (int y = 0; y < wielkosc_tab; y++)
  20.         {
  21.             cout.width(2);
  22.             cout << y + 1;
  23.             for (int x = 0; x < wielkosc_tab; x++)
  24.             {
  25.                 cout.width(2);
  26.                 cout << plansza[y][x];
  27.             }
  28.             cout << endl;
  29.         }
  30.     }
  31. ////////////////////////////////////////////////////dodawanie luster
  32.     void lustra()
  33.     {
  34.         for (int y = 0; y < wielkosc_tab; y++)
  35.             for (int x = 0; x < wielkosc_tab; x++)
  36.                 plansza[y][x] = '.';
  37.  
  38.         for (int i = 0; i < poziom;)
  39.         {
  40.             char znak;
  41.             int x, y, z;
  42.  
  43.             x = rand() % wielkosc_tab;
  44.             y = rand() % wielkosc_tab;
  45.             z = rand() % 2;
  46.  
  47.             if (z == 0)
  48.                 znak = '\\';
  49.             else
  50.                 znak = '/';
  51.  
  52.             if (plansza[y][x] != '\\' && plansza[y][x] != '/')
  53.             {
  54.                 i++;
  55.                 plansza[y][x] = znak;
  56.             }
  57.  
  58.         }
  59.         wypisywanie();
  60.     }
  61.  
  62. ///////////////////////////////////konstruktor klasy
  63.     klasa() {
  64.         for (int y = 0; y < wielkosc_tab; y++)
  65.             for (int x = 0; x < wielkosc_tab; x++)
  66.                 plansza[y][x] = '.';
  67.         poziom = 1;
  68.         poziomplansza = 1;
  69.     }
  70. };
  71.    
  72.    
  73.  
  74.  
  75.  
  76.  
  77. int main()
  78. {
  79.     srand(time(NULL));
  80. /////////////////////////wszystko żeby było mało tutaj
  81.     klasa karol;
  82.     karol.wypisywanie();
  83.     karol.lustra();
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement