Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- program hetman;
- uses crt;
- const rozmiar=8;
- type
- {rozmiar=8;}
- szachownica=array[1..rozmiar] of shortint;
- var
- s:szachownica;
- ilosc:longint;
- function atakujasie(x1,y1,x2,y2:shortint):boolean;
- begin
- if(x1=x2) or (y1=y2) or (abs(x1-x2)=abs(y1-y2)) then
- atakujasie:=true
- else atakujasie:=false
- end;
- procedure wypisz;
- var
- wiersz,kolumna:shortint;
- begin
- for wiersz:=1 to rozmiar do
- begin
- for kolumna:=1 to rozmiar do
- begin
- if kolumna=s[wiersz] then write('x':2)
- else write('*':2);
- {writeln;}
- end;
- writeln;
- end;
- ilosc:=ilosc+1;
- writeln('Ustawienie numer = ',ilosc);
- end;
- function wolna(x,y:shortint):boolean;
- var wiersz:shortint;
- begin
- wolna:=false;
- for wiersz:=1 to x-1 do
- if atakujasie(wiersz,s[wiersz],x,y) then exit;
- wolna:=true;
- end;
- procedure ustaw(wiersz:shortint);
- var kolumna:shortint;
- begin
- for kolumna:=1 to rozmiar do
- if wolna(wiersz,kolumna) then
- begin
- s[wiersz]:=kolumna;
- if wiersz<rozmiar then ustaw(wiersz+1)
- else wypisz;
- end;
- end;
- begin
- ilosc:=0;
- ustaw(1);
- readln;
- end.
- begin
- atakujasie;
- wypisz;
- wolna;
- ustaw;
- end.
Advertisement
Add Comment
Please, Sign In to add comment