Pages

Minggu, 22 Mei 2011

TUGAS :: HAL.3 LATIHAN 3

  • PASCAL
  • program latihan3;
    uses wincrt;
    const
    N=10;
    larik: array [1..10] of integer = (5,100,20,31,77,88,99,20,55,1);
    var
    j,k,temp : integer;
    begin
    clrscr;
    writeln ('sebelum diurutkan');
    for j:=1 to N do begin
    write(larik [j]:5);
    end;
    writeln;
    for j:=1 to N-1 do
    begin
    for k :=2 to N do
    begin
    if larik[k] < larik[k-1] then
    begin
    temp := larik[k];
    larik[k] := larik[k-1];
    larik[k-1] :=temp;
    end;
    end;
    end;
    writeln;
    writeln ('setelah diurutkan ');
    for j:=1 to N do
    begin
    write(larik[j]:5);
    end;
    writeln;
    end.
    
  • HASIL
Print Friendly and PDF

Artikel Terkait:

0 komentar:

Posting Komentar

Related Posts Plugin for WordPress, Blogger...