Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- #include <ctime>
- #include <vector>
- using namespace std;
- struct koordynaty
- {
- int x;
- int y;
- };
- enum class pole
- {
- puste, mur, poszukiwacz, przeciwnik, skarb
- };
- pole tablica[30][30];
- void uzupelnienie()
- {
- srand(time(NULL));
- vector<koordynaty> puste_pola;
- koordynaty nowy;
- for(int i = 0; i < 30; i++)
- {
- for(int j = 0; j < 30; j++)
- {
- if(i % 2 == 0 && j % 2 == 0)
- tablica[i][j] = pole::mur;
- else
- {
- tablica[i][j] = pole::puste;
- nowy.x = j;
- nowy.y = i;
- puste_pola.push_back(nowy);
- }
- }
- }
- int liczba_pustych = puste_pola.size();
- int numer = rand() % liczba_pustych;
- nowy = puste_pola[numer];
- tablica[nowy.y][nowy.x] = pole::skarb;
- }
- void wypisz_plansze()
- {
- for(int i = 0; i < 30; ++i)
- {
- for(int j = 0; j < 30; ++j)
- switch(tablica[i][j])
- {
- case pole::mur:
- cout << '#';
- break;
- case pole::skarb:
- cout << 'X';
- break;
- case pole::puste:
- cout << ' ';
- break;
- }
- cout << endl;
- }
- }
- int main()
- {
- uzupelnienie();
- wypisz_plansze();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement