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
|
program test;
uses heaptrc, crt;
type Tcoord = record
x : integer;
y : integer;
end;
type Pcoord = ^Tcoord;
var
CoordApple : Pcoord;
function Aleatoire : Pcoord;
var
PcoordApple : Pcoord;
begin
new(PcoordApple); {allocation mémoire}
PcoordApple^.x := random(100);
pcoordApple^.y := random(100);
Aleatoire := PcoordApple;
end;
begin
randomize;
CoordApple := Aleatoire; {Récupération du résultat de la fonction}
writeln(coordApple^.x,' ',coordApple^.y);
dispose(CoordApple); {libération mémoire}
end. |
Partager