Friday, March 6, 2009

Pascal, What's That!

Hi..my Univ. Students, from now on, I change my post to English not Indoneisan anymore. Just calm down... It doesn't mean that I don't Love Indonesian due to Egnlish is International Languange, so I hope our friend who camo from Abroad can understan what mypost are.


In this section, we will try to make program on how to searching via "buble sorting", well You can easily, practice this programvia Pascal or Delphi software development, want to know, here is the source code :

program Try_bubble_sort;
uses wincrt;
type
data=array[1..1000] of integer;
procedure masukan(var x:data;n:integer);
var i:integer;
begin
for i:=1 to n do
begin
write('Masukkan data ke ',i,' = ');readln(x[i]);
end;
end;

procedure trybubblesort(var x:data;n:integer);
var i,j:integer;t:byte;
begin
for i:=1 to n-1 do
for j:=1 to n-1 do
if x[j]>x[j+1] then
begin
t:=x[j];
x[j]:=x[j+1];
x[j+1]:=t;
end;
end;

procedure tampil(x:data;n:integer);
var i:integer;
begin
for i :=1 to n do
writeln(x[i]);
end;

var
y:data;
m:integer;
begin
clrscr;
write('masukkan jumlah data = ');readln(m);
masukan(y,m);
writeln;
writeln('Data sebelum diurutkan = ');
tampil(y,m);
trybubblesort(y,m);
writeln;
writeln('Data setelah diurutkan =');
tampil(y,m);
end.

Well.. Don't forget to Install Pascal to run this program, do not use Word,..Hehemh..:).

Created By Ader

0 comments:

  © Blogger templates The Professional Template by Ourblogtemplates.com 2008

Back to TOP