(* procedure.4.pasc *) (* procedure, perform the * 1. recursive procedure/function call *) program Procedure4 is var counter: integer; ina, inb: integer; a,b: char; function chswap(var x, y: char) return integer is var temp: char; begin temp := x; x := y; y := temp; return ina; end; procedure tower (count : integer; source : char; destination : char; spare : char) is begin if count = 1 then counter := counter + 1; write(counter, ' Move piece from pole ', source, ' to ', destination); write('\n'); else tower(count - 1, source, spare, destination); tower(1, source, destination, spare); tower(count - 1, spare, destination, source) endif end; begin write('Give me an integers -> '); read(ina); a := 'A'; b := 'Z'; write(a, '<--> ', b); write('\n'); inb := chswap(a, b); write(a, '<--> ', b); write('\n'); write(ina, inb, '\n'); counter := 0; (* recursive *) tower(5, 'a', 'b', 'c'); end. (* * INPUT: * Give me an integers -> 38 * OUTPUT: * A <--> Z * Z <--> A * 38 38 * 1 Move piece from pole a to b * 2 Move piece from pole a to c * 3 Move piece from pole b to c * 4 Move piece from pole a to b * 5 Move piece from pole c to a * 6 Move piece from pole c to b * 7 Move piece from pole a to b * 8 Move piece from pole a to c * 9 Move piece from pole b to c * 10 Move piece from pole b to a * 11 Move piece from pole c to a * 12 Move piece from pole b to c * 13 Move piece from pole a to b * 14 Move piece from pole a to c * 15 Move piece from pole b to c * 16 Move piece from pole a to b * 17 Move piece from pole c to a * 18 Move piece from pole c to b * 19 Move piece from pole a to b * 20 Move piece from pole c to a * 21 Move piece from pole b to c * 22 Move piece from pole b to a * 23 Move piece from pole c to a * 24 Move piece from pole c to b * 25 Move piece from pole a to b * 26 Move piece from pole a to c * 27 Move piece from pole b to c * 28 Move piece from pole a to b * 29 Move piece from pole c to a * 30 Move piece from pole c to b * 31 Move piece from pole a to b *)