jan0s1k

Hetman ja :P

Apr 19th, 2013
96
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 1.30 KB | None | 0 0
  1. program hetman;
  2.  uses crt;
  3.  const rozmiar=8;
  4.  type
  5.   {rozmiar=8;}
  6.   szachownica=array[1..rozmiar] of shortint;
  7.  var
  8.   s:szachownica;
  9.   ilosc:longint;
  10.  function atakujasie(x1,y1,x2,y2:shortint):boolean;
  11.   begin
  12.    if(x1=x2) or (y1=y2) or (abs(x1-x2)=abs(y1-y2)) then
  13.     atakujasie:=true
  14.    else atakujasie:=false
  15.   end;
  16.   procedure wypisz;
  17.    var
  18.     wiersz,kolumna:shortint;
  19.    begin
  20.     for wiersz:=1 to rozmiar do
  21.      begin
  22.       for kolumna:=1 to rozmiar do
  23.        begin
  24.         if kolumna=s[wiersz] then write('x':2)
  25.         else write('*':2);
  26.         {writeln;}
  27.        end;
  28.       writeln;
  29.      end;
  30.      ilosc:=ilosc+1;
  31.      writeln('Ustawienie numer = ',ilosc);
  32.    end;
  33.   function wolna(x,y:shortint):boolean;
  34.    var wiersz:shortint;
  35.    begin
  36.     wolna:=false;
  37.     for wiersz:=1 to x-1 do
  38.      if atakujasie(wiersz,s[wiersz],x,y) then exit;
  39.     wolna:=true;
  40.    end;
  41.   procedure ustaw(wiersz:shortint);
  42.    var kolumna:shortint;
  43.    begin
  44.     for kolumna:=1 to rozmiar do
  45.       if wolna(wiersz,kolumna) then
  46.        begin
  47.         s[wiersz]:=kolumna;
  48.         if wiersz<rozmiar then ustaw(wiersz+1)
  49.         else wypisz;
  50.        end;
  51.      end;
  52.     begin
  53.      ilosc:=0;
  54.      ustaw(1);
  55.      readln;
  56.     end.
  57.   begin
  58.    atakujasie;
  59.    wypisz;
  60.    wolna;
  61.    ustaw;
  62.   end.
Advertisement
Add Comment
Please, Sign In to add comment