program sisipbelakang;
uses crt;
type pointer = ^simpul;
simpul = record
data : string;
next : pointer;
end;
var p, baru, bantu : pointer;
nama : string;
begin
new(p); p := nil;
write('masukkan nama ( x =selesai ) : '); readln(nama);
repeat
new(baru);
baru^.data := nama;
baru^.next := nil;
if p = nil then p := baru
else
begin
baru^.next := p;
p := baru;
end;
write('masukkan nama ( x = selesai ) : '); readln(nama);
until nama = 'x';
bantu := p;
while bantu^.next <> nil do
begin
write(bantu^.data, ' ');
bantu := bantu^.next;
end;
write(bantu^.data);
readln;
end.
Tidak ada komentar:
Posting Komentar