Skip to main content

Source Code Record dan Array dalam Pascal

uses wincrt;
type tabel_tf = record
                      jfilm:string;
                      tjual:integer;
                end;
var tf:array [1..10] of tabel_tf;
    n,i,j:integer;
    t:tabel_tf;
begin
     write('Jumlah Film: ');
     readln(n);
     for i:=1 to n do
     begin
          write('Judul Film : ');
          readln(tf[i].jfilm);
          write('Tiket Terjual : ');
          readln(tf[i].tjual);
     end;
     begin
          for i:=1 to n do
              for j:=1 to n-1 do
                  if tf[j].tjual < tf[j+1].tjual then
                  begin
                       t:=tf[j];
                       tf[j]:=tf[j+1];
                       tf[j+1]:=t;
                  end;
     end;
     writeln('Judul Film                         Tiket Terjual');
     for i:=1 to n do
     begin
          writeln(tf[i].jfilm,tf[i].tjual:25);
     end;
end.

Comments