-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHANOJUS.BAK
More file actions
44 lines (32 loc) · 806 Bytes
/
HANOJUS.BAK
File metadata and controls
44 lines (32 loc) · 806 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
program Hanojaus_Bokstai;
uses crt;
var zied : integer;
procedure han (zied : integer; pr, t, gal : char);
begin
if zied > 0 then
begin
han (zied - 1, pr, gal, t);
writeln ('Zieda ', zied, ' is ', pr,' i ', gal);
han (zied - 1, t, pr, gal);
end
end;
procedure Towers (count : Integer; source, dest, spare : char);
begin
if count
then
writeln ('Zieda ', count, ' is ', source,' i ', dest);
else
begin
Towers (count-1, source, spare, dest);
Towers (1, source, dest, spare);
Towers (count-1, spare, source, dest);
end
end;
begin
clrscr;
write ('Kiek turite ziedu? ');
readln (zied);
han (zied, '1', '2', '3');
towers (zied, '1', '3', '2');
readkey;
end.