uses crt;
type pointer=^typedata;
typedata = record
nilai : integer;
berikut : pointer;
end;
var list :pointer;
procedure mas_dep(var L : pointer; x : Integer);
var baru : pointer;
begin
new(baru);
baru^.Nilai:=x;
baru^.Berikut:= nil;
if L= nil then L:=baru
else
begin
baru^.berikut :=L;
L:= baru;
end;
end;
procedure cetak (L:pointer);
var bantu : pointer;
begin
bantu:= L;
while bantu <> nil do
begin
write (bantu^.Nilai:3);
Bantu:=bantu^.Berikut;
end;
end;
var bil, bil2 : integer;
JB : char;
begin
clrscr;
new(list);
list:=nil;
jb:='Y';
writeln;
writeln (' ===Program Linked List===');
writeln;
writeln (' Masuk depan');
while upcase(Jb)='Y' do
begin
writeln;
write ('Masukkan bilangan : '); readln(bil);
mas_dep(list,bil);
write ('Lagi [Y/T] : '); readln(Jb);
end;
cetak(list);
writeln;
readln;
end.
Tidak ada komentar:
Posting Komentar