Tugas Struktur Data [2]
Selasa, 04 Oktober 20110 komentar
program devid_dot_belilas_dot_com;
uses wincrt;
{================================}
{ Nama : DEVID EKHA HIDAYAT }
{ Email : devid@belilas.com }
{ blog : devid.belilas.com }
{================================}
Type
Barang = record
Kode : string ;
Nama : string ;
harga : longint ;
end;
{==================================}
{ Then there will be khilafah }
{ }
{ On method of prophethood }
{==================================}
var
de, v, id : longint;
F :array [1..5] of barang ;
Begin
{cara untuk mengisikan data}
F[1].kode := ('a1');
F[1].Nama := ('netbook');
F[1].Harga := (2499000);
F[2].kode := ('a2');
F[2].Nama := ('handphone');
F[2].Harga := (2200000);
F[3].kode := ('a3');
F[3].Nama := ('notebook');
F[3].Harga := (4290000);
F[4].kode := ('a4');
F[4].Nama := ('printer');
F[4].Harga := (699000);
F[5].kode := ('a5');
F[5].Nama := ('modem');
F[5].Harga := (475000);
{Cara untuk menampilkan}
write('Kode : '); writeln (F[1].kode);
write('Nama : '); writeln(F[1].Nama);
write('Harga : '); writeln(F[1].Harga);
writeln;
write('Kode : '); writeln (F[2].kode);
write('Nama : '); writeln(F[2].Nama);
write('Harga : '); writeln(F[2].Harga);
writeln;
write('Kode : '); writeln (F[3].kode);
write('Nama : '); writeln(F[3].Nama);
write('Harga : '); writeln(F[3].Harga);
writeln;
write('Kode : '); writeln (F[4].kode);
write('Nama : '); writeln(F[4].Nama);
write('Harga : '); writeln(F[4].Harga);
writeln;
write('Kode : '); writeln (F[5].kode);
write('Nama : '); writeln(F[5].Nama);
write('Harga : '); writeln(F[5].Harga);
for de := 2 to 5 do
begin
id := F[de].Harga;
v := de - 1;
while (id < F[v].Harga)
and (v > 0) do
begin
F[v+1].Harga := f[v].Harga;
v := v - 1;
end;
F[v+1].Harga := id ;
end;
writeln;
write('Barang Dengan Harga Termahal : ');
if (F[de].Harga=2499000) then
begin
write('Kode : '); writeln(F[1].kode);
write(' Nama : '); writeln(F[1].nama);
write(' Harga : '); writeln(F[de].harga);
end
else
if (F[de].Harga=2200000) then
begin
write('Kode : '); writeln(F[2].kode);
write(' Nama : '); writeln(F[2].nama);
write(' Harga : '); writeln(F[de].harga);
end
else
if (F[de].Harga=4290000) then
begin
write('Kode : '); writeln(F[3].kode);
write(' Nama : '); writeln(F[3].nama);
write(' Harga : '); writeln(F[de].harga);
end
else
if (F[de].Harga=699000) then
begin
write('Kode : '); writeln(F[4].kode);
write(' Nama : '); writeln(F[4].nama);
write(' Harga : '); writeln(F[de].harga);
end
else
if (F[de].Harga=475000) then
begin
write('Kode : '); writeln(F[5].kode);
write(' Nama : '); writeln(F[5].nama);
write(' Harga : '); writeln(F[de].harga);
end;
end.
Posting Komentar