Tugas
Praktikum Ke-6
Nama : Achmad Kharis
NIM :
J1F114002
Kelompok
: 3 (Tiga)
1.
Screenshot
Program
Gambar 1.1 Input bilangan
pertama.
Gambar 1.2 Input bilangan
kedua.
Gambar 1.3 Input bilangan
ketiga.
Gambar 1.4 Output Hasil.
2. Source Code
Uses crt;
Type pointer
= ^typedata;
Typedata = record
Nilai : Integer;
Berikutnya : pointer;
End;
Var list
:pointer;
Procedure
mas_dep(var L : pointer; x : Integer);
Var baru :
pointer;
Begin
New(baru);
Baru^.Nilai:=x;
Baru^.Berikutnya:= nil;
If L= nil then L:=baru
Else
Begin
Baru^.berikutnya :=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^.Berikutnya;
End;
End;
Var bil, bil2 : integer;
Jwb : char;
Begin
Clrscr;
New(list);
List:=nil;
Writeln ('Program linked List');
Writeln;
Writeln (' Masuk depan');
Repeat
Begin
Writeln;
Write ('Masukkan bilangan : ');
readln(bil);
mas_dep(list,bil);
Write ('Lagi [Y/T] : '); readln(jwb);
End;
Until jwb='T';
Write(‘Hasil : ‘);
Cetak(list);
Writeln;
Readln;
End.
|
Posting Komentar