program list1;
uses crt;
type list = ^node;
node=record
data: record
kode:string[5];
harga:real;
end;
next:list;
end;
var
L:list;
Procedure inisialisasi(var L:list);
begin
L:=nil;
end;
Procedure tambahbarusimpul(kode:string;harga:real; var L:List);
var
pbaru,ekor:list;
begin
ekor:=L;
if ekor <> NIL then
begin
new(pbaru);
pbaru^.data.kode:=kode;
pbaru^.data.harga:=harga;
pbaru^.next:=NIL;
while ekor^.next<>nil do
ekor:=ekor^.next;
ekor^.next:=pbaru;
end
else
begin
new(L);
L^.data.kode:=kode;
L^.data.harga:=harga;
L^.next:=NIL;
end;
end;
procedure cetaksenarai(L:list);
var
ekor:list;
begin
ekor:=L;
if ekor <> NIL then
while ekor<>nil do
begin
writeln(ekor^.data.kode);
writeln(ekor^.data.harga:8:2);
ekor:=ekor^.next;
end
else
writeln('kosong');
writeln;
end;
procedure cariganti(var a:list);
var
bantu: list;
kode :string[5];
begin
if a = nil then Writeln('List tidak ada')
else
begin
write('masukkan kode barang : ');
readln(kode);
bantu :=a;
while (bantu<> nil) Do
begin
if bantu^.data.kode= kode then
bantu^.data.harga:=bantu^.data.harga*1.5;
bantu:=bantu^.next;
end;
end;
end;
BEGIN
inisialisasi(L);
cariganti(L);
tambahbarusimpul('a1123',10000,L);
tambahbarusimpul('a1124',11000,L);
cetaksenarai(L);
cariganti(L);
cetaksenarai(L);
readln;
end.
Monday, August 9, 2010
Subscribe to:
Post Comments (Atom)
1 comment:
You seems to be an expert in this field, Great article and keep up the good work, my buddy recommended me it.
My blog:
rachat credit professionnel aussi rachat de credit surendettement
Post a Comment