Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <stdlib.h>
- #include <vector>
- using std::vector;
- using namespace std;
- class Hetman
- {
- public:
- int x;
- int y;
- int wielkosc;
- bool aktywny;
- vector<vector<bool> > atakowanePola;
- //bool* atakowanePola;
- //bool** atakowanePola2;
- public:
- Hetman()
- {
- x=0;
- y=0;
- aktywny=false;
- // bool atakowanePola2 = new bool*[3];
- // for (int i = 0; i < 3; ++i )
- // {
- // atakowanePola2[i] = new bool[3];
- // }
- }
- Hetman(int wielkosc, int x, int y)
- {
- this->x=x;
- this->y=y;
- this->wielkosc=wielkosc;
- aktywny=true;
- atakowanePola.resize(wielkosc);
- for(int i=0; i<wielkosc; i++)
- atakowanePola[i].resize(wielkosc);
- for(int i=0; i<wielkosc; i++)
- {
- for(int j=0; j<wielkosc; j++)
- {
- if(i==y)
- atakowanePola[i][j]=true;
- if(j==x)
- atakowanePola[i][j]=true;
- if(abs(x-i)==abs(y-j))
- atakowanePola[i][j]=true;
- }
- }
- //pokazAtak();
- // atakowanePola = new bool[wielkosc*wielkosc];
- // for(int i=0; i<wielkosc*wielkosc; i++) atakowanePola[i]=false;
- //
- // for(int i=0; i<wielkosc*wielkosc; i++)
- // {
- // if(x%wielkosc==i%wielkosc) atakowanePola[i]=true;
- //
- // }
- }
- void ustaw(int wielkosc, int x, int y)
- {
- this->x=x;
- this->y=y;
- this->wielkosc=wielkosc;
- aktywny=true;
- atakowanePola.resize(wielkosc);
- for(int i=0; i<wielkosc; i++)
- atakowanePola[i].resize(wielkosc);
- for(int i=0; i<wielkosc; i++)
- {
- for(int j=0; j<wielkosc; j++)
- {
- if(i==y)
- atakowanePola[i][j]=true;
- if(j==x)
- atakowanePola[i][j]=true;
- if(abs(x-i)==abs(y-j))
- atakowanePola[i][j]=true;
- }
- }
- }
- void zedjmij()
- {
- x=0;
- y=0;
- aktywny=false;
- }
- void pokazAtak()
- {
- cout << "Atakowane pola:\n";
- for(int i=0; i<wielkosc; i++)
- {
- for(int j=0; j<wielkosc; j++)
- {
- cout << atakowanePola[i][j];
- if(j!=wielkosc-1) cout << ":";
- }
- cout << endl;
- }
- }
- };
- class Plansza
- {
- private:
- int rozmiar;
- public:
- Plansza(int wielkosc)
- {
- rozmiar=wielkosc;
- }
- void rozwiaz()
- {
- Hetman tab[rozmiar];
- }
- };
- int main()
- {
- //cout << a.atakowanePola[];
- vector<vector<int> > tablica2D;
- tablica2D.resize(3);
- for(int i=0; i<3; i++)
- tablica2D[i].resize(2);
- tablica2D[0][1]=3;
- for(int i=0; i<3; i++)
- {
- for(int j=0; j<2; j++)
- {
- cout << tablica2D[i][j];
- }
- cout << endl;
- }
- cout << "Koniec testu 1\n\n";
- Hetman a(5, 1, 0);
- a.pokazAtak();
- //cout << a.atakowanePola[1][0];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement