program urut data..menggunakan bahasa pascal
uses crt;
label 1;
type
larik=array[1..10] of integer;
garis=array[1..80,1..25] of char;
var
indeks,a,x,x1,y,i,n,j,temp:integer;
data:larik;
find:boolean;
gambar:garis;
pilih:char;
{ ============================== Gambar Kotak =========================== }
procedure kotak (n:integer);
begin
clrscr;
textcolor(white);
for i:= 1 to 3 do
begin
for j:= 1 to (n*5) do
begin
If (i=1) and (j=1) then
begin
gambar[i,j]:='Ú';
gotoxy(30+j,2+(i-1));
write(gambar[i,j]);
end;
If (i=1) and ((j>1) and (j mod 5=0)) then
begin
if (j<(n*5)) then
begin
gambar[i,j]:='Â';
gotoxy(30+j,2+(i-1));
write(gambar[i,j]);
end
else
begin
gambar[i,j]:='¿';
gotoxy(30+j,2+(i-1));
write(gambar[i,j]);
end;
end;
If (i=1) and ((j>1) and (j mod 5<>0))then
begin
gambar[i,j]:='Ä';
gotoxy(30+j,2+(i-1));
write(gambar[i,j]);
end;
If (i>1) and ((j>1) and (j mod 5=0)) then
begin
gambar[i,j]:='³';
gotoxy(30+j,2+(i-1));
write(gambar[i,j]);
end;
If (i>1) and (j=1) then
begin
gambar[i,j]:='³';
gotoxy(30+j,2+(i-1));
write(gambar[i,j]);
end;
If (i=3) and (j=1) then
begin
gambar[i,j]:='À';
gotoxy(30+j,2+(i-1));
write(gambar[i,j]);
end;
if (i=3) and (((j>1) and (j<(n*5)) and (j mod 5<>0))) then
begin
gambar[i,j]:='Ä';
gotoxy(30+j,2+(i-1));
write(gambar[i,j]);
end;
if (i=3) and (((j>1) and (j<(n*5)) and (j mod 5=0))) then
begin
gambar[i,j]:='Á';
gotoxy(30+j,2+(i-1));
write(gambar[i,j]);
end;
if (i=3) and (j=(n*5)) then
begin
gambar[i,j]:='Ù';
gotoxy (30+j,2+(i-1));
write(gambar[i,j]);
end;
end;
end;
end;
{ ========================== U R U T D A T A ============================ }
Procedure urut (n:integer;var data:larik);
var
temp,a,x,y:integer;
begin
for i:= 1 to n do
for j:= n downto 1 do
if data[j] begin
temp:=data[j];
data[j]:=data[j-1];
data[j-1]:=temp;
end;
for a:= 1 to n do
begin
y:=3;
if a=1 then
begin
x:=round((a*5)/2);
gotoxy(30+x,y);
write(data[a]);
end;
if a>1 then
begin
x:=round((a*5)/2)+round((x+1)/2);
gotoxy(30+x,y);
write(data[a]);
end;
end;
end;
{ =========== ANIMASI CREDIT ============ }
procedure end_intro(text : string);
var len,pos : integer;
column : integer;
i,m,y : integer;
begin
len := length(text);
column := 40-(LEN div 2);
for i:= 1 to len do
begin
textcolor(11); gotoxy((column-1)+i,18); write (text[i]); delay(50);
end;
delay(1000);
pos := len;
for i := 1 to len do
begin
gotoxy(1,18);
clreol;
gotoxy(column,18);
textcolor(11);
write(text);
delete(text,pos,1);
dec(pos,1);
y := pos+column;
for m := pos+column to 80 do
begin
gotoxy(y,18);
textcolor(9);
write('-');
delay(5);
gotoxy(y,18);
write(' ');
inc(y,1);
end;
textcolor(black);
end;
end;
{ ============ Program Utama ========== }
Begin
repeat
1:clrscr;
textcolor(white);
writeln ('ÉÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍ»');
writeln ('º º');
writeln ('º NAMA : power. p. atasoge º');
writeln ('º NIM : 000000000 º');
writeln ('º º');
write ('º ');
write (' VISUALISASI ');
writeln (' º');
writeln ('º SEARCHING BERURUTAN º');
writeln ('ÈÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍÍͼ');
writeln;
write ('Jumlah data (1-10) : ');
{$I-}
readln (n);
{$I+}
if IOresult=0 then
textcolor(yellow);
writeln ('*) Data yang anda masukkan akan diurutkan terlebih dulu');
until (n>=1) and (n<=10) and (IOresult=0);
textcolor(white);
for i:= 1 to n do
begin
write ('Data [',i,'] = ');
readln(data[i]);
end;
write ('Data yang dicari = '); readln(x);
writeln ('Press any key to visualization...');
readkey;
clrscr;
textcolor(green);
kotak(n);
urut(n,data);
writeln; textcolor(green);
writeln('Algoritmanya : ');
writeln; textcolor(white);
writeln('find:=false;');
writeln('i:=1;');
writeln('repeat');
writeln(' if x=data[i] then');
writeln(' begin');
writeln(' find:=true;');
writeln(' indeks:=i;');
writeln(' end');
writeln(' else i:=i+1;');
writeln('until (find=true) or (i>n);');
for i:= 1 to 16 do
begin
textcolor(blue);
gotoxy (29,i); write('³');
end;
for i:=1 to 80 do
begin
textcolor(blue);
gotoxy (i,16); write('Ä');
if i=29 then
begin
gotoxy (i,16); write('Á');
end;
end;
textcolor(green);
gotoxy (31,1);writeln('Data setelah diurut :');
textcolor(white);
gotoxy(30,8); write ('Banyak Data = ',n);
gotoxy(30,9); write ('Data yang dicari = ',x);
textcolor(yellow); gotoxy (1,6); writeln('find:=false;');
find:=false;
gotoxy(30,10); clreol;
textcolor(red); gotoxy(30,10); write ('Belum ketemu'); delay (2500);
textcolor(white); gotoxy (1,6); writeln('find:=false;');
textcolor(yellow); gotoxy(1,7); writeln('i:=1;');
i:=1; delay (2500);
y:=5;
repeat
textcolor(white); gotoxy(1,7); writeln('i:=1;');
textcolor(12);
gotoxy(30,7); write ('Indeks ke-',i);
textcolor(yellow);
gotoxy(1,8); writeln('repeat');
if i=1 then
begin
textcolor(yellow);
x1:=round((i*5)/2);
gotoxy(30+x1,y);
write('i');
end;
if i>1 then
begin
textcolor(yellow);
x1:=round((i*5)/2)+round((x1+1)/2);
gotoxy(30+x1,y);
write('i');
end;
textcolor(white);
gotoxy(30,11); write ('Apakah ',data[i],' sama dengan ',x,' ?'); delay(2500);
if x=data[i] then
begin
textcolor(white);
gotoxy(1,8); writeln('repeat');
textcolor(yellow); gotoxy (1,9); writeln(' if x=data[i] then');
textcolor(green);gotoxy (57,11); write ('Ya'); delay(3000);
textcolor(white); gotoxy (1,9); writeln(' if x=data[i] then');
textcolor(yellow); gotoxy(1,11);writeln(' find:=true;');
find:=true;
gotoxy(30,10); clreol;
textcolor(green); gotoxy(30,10); write ('Data ditemukan'); delay (3000);
textcolor(white); gotoxy(1,11);writeln(' find:=true;');
textcolor(yellow);gotoxy (1,12);writeln(' indeks:=i;');
indeks:=i;
gotoxy(30,10); clreol;
textcolor(green); gotoxy(30,10); write ('Indeks disimpan'); delay (3000);
textcolor(white);gotoxy (1,12);writeln(' indeks:=i;');
textcolor(yellow);
gotoxy (1,15);writeln('until (find=true) or (i>n);');
end
else
begin
textcolor(white);
gotoxy(1,8); writeln('repeat');
textcolor(yellow);
gotoxy (1,14); writeln(' else i:=i+1;');
textcolor(red);
gotoxy (57,11); write ('Tidak'); delay(2500);
gotoxy (56,11); clreol;
gotoxy(30+x1,y); write(' ');
i:=i+1;
textcolor(white);
gotoxy (1,14); writeln(' else i:=i+1;');
end;
until (find=true) or (i>n);
writeln;
if find=true then
begin
textcolor(yellow);
gotoxy (1,15);writeln('until (find=true) or (i>n);'); delay(2000);
textcolor(white);
gotoxy (1,15);writeln('until (find=true) or (i>n);');
textcolor(yellow);
gotoxy (30,13); write (x,' berada pada indeks ke-',indeks); delay (2500);
end
else
begin
textcolor(yellow);
gotoxy (1,15);writeln('until (find=true) or (i>n);'); delay(2000);
textcolor(white);
gotoxy (1,15);writeln('until (find=true) or (i>n);');
textcolor(yellow);
gotoxy (30,13); write ('Data yang dicari tidak ada!!!'); delay(2500);
end;
repeat
textcolor(white);
gotoxy (1,18); clreol;
gotoxy (1,18); write ('Ulangi Program (y/t)? '); readln(pilih);
case upcase(pilih) of
'Y' : goto 1;
'T' : else;
end;
until (upcase(pilih)='Y') or (upcase(pilih)='T');
gotoxy (1,18); clreol;
end_intro('Copyright by Pingky A. R. Leo Lede');
end.

