Vytvorené: 19. 03. 2014 Tlačiť
program HanojskeVezeOk;
var tyce: array[1..3,0..5] of integer; i,j: integer; z,na: integer; top1,top2,top3: integer; pom,pokus:integer;
begin top1:=5; tyce [1,1]:=10; tyce [1,2]:=8; tyce [1,3]:=6; tyce [1,4]:=4; tyce [1,5]:=2; top2:=0; tyce [2,1]:=0; tyce [2,2]:=0; tyce [2,3]:=0; tyce [2,4]:=0; tyce [2,5]:=0; top3:=0; tyce [3,1]:=0; tyce [3,2]:=0; tyce [3,3]:=0; tyce [3,4]:=0; tyce [3,5]:=0;
writeln; for i:=5 downto 1 do begin for j:=1 to 3 do begin if (tyce[j,i])=10 then begin write(' xxxxxIxxxxx '); end; if (tyce[j,i])= 8 then begin write(' xxxxIxxxx '); end; if (tyce[j,i])= 6 then begin write(' xxxIxxx '); end; if (tyce[j,i])= 4 then begin write(' xxIxx '); end; if (tyce[j,i])= 2 then begin write(' xIx '); end; if (tyce[j,i])= 0 then begin write(' I '); end; end; writeln; end;repeat writeln; writeln ('Kotuc z ktorej tyce chces premiestnit?'); readln(z); writeln ('Kotuc chces premiestnit na ktoru tyc?'); readln(na); if (z=na) then begin writeln ('POMYLIL SI SA.'); end; if (z=1) and (na=2) then begin if (tyce[2,top2]>tyce[1,top1]) or (tyce[2,top2]=0)then begin top2:=top2+1; tyce[2,top2]:=tyce[1,top1]; top1:=top1-1; tyce[1,top1+1]:=0; pokus:=pokus+1; end else writeln ('NEMOZES PREMIESTNIT > KOTUC NA <.') end;
if (z=2) and (na=1) then begin if (tyce[1,top1]>tyce[2,top2]) or (tyce[1,top1]=0)then begin top1:=top1+1; tyce[1,top1]:=tyce[2,top2]; top2:=top2-1; tyce[2,top2+1]:=0; pokus:=pokus+1; end else writeln ('NEMOZES PREMIESTNIT > KOTUC NA <.') end;
if (z=1) and (na=3) then begin if (tyce[3,top3]>tyce[1,top1]) or (tyce[3,top3]=0)then begin top3:=top3+1; tyce[3,top3]:=tyce[1,top1]; top1:=top1-1; tyce[1,top1+1]:=0; pokus:=pokus+1; end else writeln ('NEMOZES PREMIESTNIT > KOTUC NA <.') end;
if (z=2) and (na=3) then begin if (tyce[3,top3]>tyce[2,top2]) or (tyce[3,top3]=0)then begin top3:=top3+1; tyce[3,top3]:=tyce[2,top2]; top2:=top2-1; tyce[2,top2+1]:=0; pokus:=pokus+1; end else writeln ('NEMOZES PREMIESTNIT > KOTUC NA <.') end;
if (z=3) and (na=1) then begin if (tyce[1,top1]>tyce[3,top3]) or (tyce[1,top1]=0)then begin top1:=top1+1; tyce[1,top1]:=tyce[3,top3]; top3:=top3-1; tyce[3,top3+1]:=0; pokus:=pokus+1; end else writeln ('NEMOZES PREMIESTNIT > KOTUC NA <.') end;
if (z=3) and (na=2) then begin if (tyce[2,top2]>tyce[3,top3]) or (tyce[2,top2]=0)then begin top2:=top2+1; tyce[2,top2]:=tyce[3,top3]; top3:=top3-1; tyce[3,top3+1]:=0; pokus:=pokus+1; end else writeln ('NEMOZES PREMIESTNIT > KOTUC NA <.') end; writeln;
for i:=5 downto 1 do begin for j:=1 to 3 do begin if (tyce[j,i])=10 then begin write(' xxxxxIxxxxx '); end; if (tyce[j,i])= 8 then begin write(' xxxxIxxxx '); end; if (tyce[j,i])= 6 then begin write(' xxxIxxx '); end; if (tyce[j,i])= 4 then begin write(' xxIxx '); end; if (tyce[j,i])= 2 then begin write(' xIx '); end; if (tyce[j,i])= 0 then begin write(' I '); end; end; writeln; end; writeln; writeln ('POCET PREMIESTNENI =',pokus); writeln; writeln ('HRAME DALEJ (NIE=0)?'); readln(pom);until pom=0;
end.
![]()
· Simulácie z fyziky· O Slovensku po slovensky· Slovenské kroje· Kurz národopisu· Diela maliarov· Kontrolné otázky, Domáce úlohy, E-testy - Priemysel· Odborné obrázkové slovníky· Poradňa žiadaného učiteľa· Rýchlokurz Angličtiny. Rozprávky (v mp3)· PREHĽADY (PRIBUDLO, ČO JE NOVÉ?)Seriály:· História sveta (1÷6)· História Slovenska (1÷5)· História módy (1÷5).
Členstvo na portáli
Poznámka pre autora
Copyright © 2013-2025 Wesline, s.r.o. Všetky práva vyhradené. Mapa stránky ako tabuľka | Kurzy | Prehľady |