Selasa, 14 April 2015

Kode Pascal ' Urut Data'

PROGRAM PASCAL


program data;

uses wincrt;

var
 i,j,n:integer;
 x: array[0..6] of integer;

begin
 writeln('Program Urut Data');
 write ('Masukkan Banyak Data '); readln (n);

 for i:=1 to n do
  begin
   write ('Masukkan Data ke ',i,':'); readln (x[i]);
  end;

for i:=1 to n-1 do
for j:=1 to n-1 do
 begin
  if x[j]>x[j+1] then
   begin
    x[0]:=x[j];
    x[j]:=x[j+1];
    x[j+1]:=x[0];
   end;

 end;

 writeln('Data Setelah Diurut');
 for i:=1 to n do
  begin
   writeln('Data ke ',i,':',x[i]);
  end;

end.

0 komentar:

Posting Komentar