program linked_list;
uses crt;
type ptrdata = ^recorddata;
recorddata = record
item : string;
berikut : ptrdata
end;
var pd : ptrdata;
elem : string;
procedure node_baru(var baru: ptrdata; elemen: string);
var ps: ptrdata;
begin
new(ps);
new(baru);
baru^.item := elemen;
baru^.berikut := nil;
end;
Procedure tambah_depan(Var depan : ptrData; elemen : string);
Var ps :ptrdata;
Begin
new(ps);
new(depan);
node_baru(ps,elemen);
ps^.berikut := pd;
pd:=ps ;
End;
begin
clrscr;
new(pd);
elem := 'Nama : Eko Prayogo';
tambah_depan(pd, elem);
writeln(pd^.item);
elem := 'NIM : J1F114075';
tambah_depan(pd, elem);
writeln(pd^.item);
writeln;
elem := 'Nama : Eka Prayoga';
tambah_depan(pd, elem);
writeln(pd^.item);
elem := 'NIM : J1F114076';
tambah_depan(pd, elem);
writeln(pd^.item);
readln;
end.
Senin, 20 April 2015
link list
16.08
No comments
0 komentar:
Posting Komentar