Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <cstdlib>
- using namespace std;
- const int P_ROZMIAR = 8;
- const char czarny = 'x';
- const char bialy = 'o';
- struct pole
- {
- bool czy_nieaktywne;
- bool czy_wolne;
- char znak_litera;
- char znak_cyfra;
- };
- void inicjalizacja(pole plansza[P_ROZMIAR][P_ROZMIAR]);
- void wyswietlanie_planszy(pole plansza[P_ROZMIAR][P_ROZMIAR]);
- int main()
- {
- pole plansza[P_ROZMIAR][P_ROZMIAR];
- inicjalizacja(plansza);
- system("pause");
- return 0;
- }
- void inicjalizacja(pole plansza[P_ROZMIAR][P_ROZMIAR])
- {
- for (int w = 0;w < P_ROZMIAR;w++)
- for (int k = 0;k < P_ROZMIAR;k++)
- plansza[w][k].czy_nieaktywne = true;
- for (int w = 1; w < P_ROZMIAR - 1; w++)
- for (int k = 1; k < P_ROZMIAR - 1; k++)
- {
- plansza[w][k].czy_nieaktywne = false;
- plansza[w][k].czy_wolne = false;
- if (w % 2 == 1)
- if (k == 3 || k == 4)
- plansza[w][k].znak_litera = bialy;
- else
- plansza[w][k].znak_litera = czarny;
- else
- if (k == 3 || k == 4)
- plansza[w][k].znak_litera = czarny;
- else
- plansza[w][k].znak_litera = bialy;
- plansza[w][k].znak_cyfra = '1';
- }
- for(int w = 0;w < P_ROZMIAR;w+=7)
- for (int k = 2;k < 6;k++)
- {
- plansza[w][k].czy_wolne = true;
- plansza[k][w].czy_wolne = true;
- plansza[w][k].czy_nieaktywne = false;
- plansza[k][w].czy_nieaktywne = false;
- }
- wyswietlanie_planszy(plansza);
- }
- void wyswietlanie_planszy(pole plansza[P_ROZMIAR][P_ROZMIAR])
- {
- for (int w = 0;w < P_ROZMIAR;w++)
- {
- cout << P_ROZMIAR - w << " ";
- for (int k = 0;k < P_ROZMIAR; k++)
- {
- if (plansza[w][k].czy_nieaktywne) cout << " -- ";
- else if (plansza[w][k].czy_wolne) cout << "| |";
- else cout << "| " << plansza[w][k].znak_litera << plansza[w][k].znak_cyfra << " |";
- }
- cout << endl << endl;
- }
- cout << " ";
- for (char k = 'A'; k < 'A' + P_ROZMIAR;k++)
- cout << " " << k << " ";
- cout << endl << endl;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement