Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdio>
- #include <ctime>
- using namespace std;
- const int wielkosc_tab = 10;
- class klasa {
- public:
- char plansza[wielkosc_tab][wielkosc_tab];
- int poziom;
- int poziomplansza;
- ////////////////////////////////////////////////////////wypisywanie tablicy
- void wypisywanie()
- {
- system("cls");
- cout << " A B C D E F G H I J\n";
- for (int y = 0; y < wielkosc_tab; y++)
- {
- cout.width(2);
- cout << y + 1;
- for (int x = 0; x < wielkosc_tab; x++)
- {
- cout.width(2);
- cout << plansza[y][x];
- }
- cout << endl;
- }
- }
- ////////////////////////////////////////////////////dodawanie luster
- void lustra()
- {
- for (int y = 0; y < wielkosc_tab; y++)
- for (int x = 0; x < wielkosc_tab; x++)
- plansza[y][x] = '.';
- for (int i = 0; i < poziom;)
- {
- char znak;
- int x, y, z;
- x = rand() % wielkosc_tab;
- y = rand() % wielkosc_tab;
- z = rand() % 2;
- if (z == 0)
- znak = '\\';
- else
- znak = '/';
- if (plansza[y][x] != '\\' && plansza[y][x] != '/')
- {
- i++;
- plansza[y][x] = znak;
- }
- }
- wypisywanie();
- }
- ///////////////////////////////////konstruktor klasy
- klasa() {
- for (int y = 0; y < wielkosc_tab; y++)
- for (int x = 0; x < wielkosc_tab; x++)
- plansza[y][x] = '.';
- poziom = 1;
- poziomplansza = 1;
- }
- };
- int main()
- {
- srand(time(NULL));
- /////////////////////////wszystko żeby było mało tutaj
- klasa karol;
- karol.wypisywanie();
- karol.lustra();
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement