Monday, March 25, 2013

mencari Median menggunakan procedure console delphi

 Hei kawan ,,. ini dia program mencari Median menggunakan procedure console delphi.
langsung saja lihat script code dibawah ini..
silahkan copy paste untuk mencobanya  ..GRATIZ...
 semoga berhasil kawan... .
.....................................................................................................................................................

program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;

var
 I,n,J,temp :integer;
 data : array [1..10] of integer;

 procedure input ();
 begin
  write ('berapa banyak data nilai ? ');
  readln (n);
    for  I := 1 to n do
    begin
      write ('data ke-',I,'? ');
      readln (data[I]);
    end;
 end;

 procedure urut ();
 begin
   for I := 1 to n do
    begin
      for J := I+1 to n+1 do
           begin
             if data[I] > data[J] then
                begin
                  temp := data[I];
                  data[I] := data[J];
                  data[J] := temp;
                end;

           end;
      writeln ('nilai ke-',I,'= ',temp);
    end;
  end;

procedure median ();
var me : real;
begin
    if (n mod 2 > 0 ) then
        begin
         me := data[(j+1) div 2] ;
        end else
        begin
          me := (data[j div 2] + data[(j div 2)+1]) /2;
        end;
writeln ('median =',me:6:1);
end;


begin

input;
urut;
median;
readln;
end.

No comments:

Post a Comment

jangan sampai lupa waktu