21/04/15

Program Sederhana Linked List Pada Pascal

Program Linked List :
---------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------



Tampilan Program



Berikut Source Codenya:
uses crt;
type pdata = ^recorddata;
     recorddata = record
        item : string;
        berikut : pdata
     end;

var data : pdata;
    elem : string;

procedure node_baru(var baru: pdata; elemen: string);
var ps: pdata;
begin
        new(ps);
        new(baru);
        baru^.item := elemen;
        baru^.berikut := nil;
end;

Procedure tambah_depan(Var depan : pData; elemen : string);
Var  ps :pdata;
Begin
        new(ps);
        new(depan);
        node_baru(ps,elemen);
        ps^.berikut  :=  data;
        data:=ps ;
End;

begin
        clrscr;
        writeln('       Program Linked List');
        writeln;
        new(data);
        elem := ' Nama    : Muhammad Darmadi';
        tambah_depan(data, elem);
        writeln(data^.item);

        elem := ' NIM     : J1F114076';
        tambah_depan(data, elem);
        writeln(data^.item);
        writeln;

        elem := ' Nama    : Muhammad Darmadi';
        tambah_depan(data, elem);
        writeln(data^.item);

        elem := ' NIM     : J1F114076';
        tambah_depan(data, elem);
        writeln(data^.item);
        readln;
end.