[[veze]]
 
program towers;
 
const n=4;
 
type vez=record
            p:integer;
            d:array [1..n] of integer;
         end;
 
var a,b,c:vez;
 
procedure nuluj(var v:vez);
var i:integer;
begin
   v.p:=0;
   for i:=1 to n do
     v.d[i]:=0;
end;
 
procedure napln(var v:vez);
var i:integer;
begin
   for i:=1 to n do
     v.d[i]:=n-i+1;
   v.p:=n;
end;
 
procedure vypis(v:vez);
var i:integer;
begin
   for i:=1 to v.p do
     write(v.d[i],' ');
   write(' ':(2*n+2-2*v.p));
end;
 
procedure vypisVse;
begin
   vypis(a);
   write (' : ');
   vypis(b);
   write (' : ');
   vypis(c);
   writeln();
end;
 
procedure error (s: string);
begin
     writeln (s);
     halt;
end;
 
procedure krok(var x,y:vez);
begin
 
  if x.p=0 then error ('Nic!');
  if y.p=n then error ('Plno!');
  if y.p<>0 then
     if x.d[x.p]>y.d[y.p] then
        error ('Chyba!');
 
  y.p := y.p+1;
  y.d[y.p] := x.d[x.p];
 
  x.d[x.p] := 0;
  x.p := x.p - 1;
 
 
end;
 
begin
   napln(a);
   nuluj(b);
   nuluj(c);
   vypisVse;
   krok(a,c);
   vypisVse;
   readln();
end.
 
veze.txt · Last modified: 2014/04/29 14:51 by 147.32.8.115
 
Recent changes RSS feed Creative Commons License Donate Powered by PHP Valid XHTML 1.0 Valid CSS Driven by DokuWiki