Program Binary-Search;
uses crt;
const
n=10;
var
data:array[1..n] of string [1];
nm:string[10];
item:char;
z:string[n];
loc,x,y:integer;
begin
clrscr;
write('Masukkan Nama : ');readln(nm);
for x:=1 to length(nm) do
data[x]:=copy(nm,x,1);
for x:=1 to length(nm)-1 do
begin
for y:=1 to length(nm)-x do
begin
if data[y] > data[y+1] then
begin
z:=data[y];
data[y]:=data[y+1];
data[y+1]:=z;
end;end;end;
write('Hasil Ascending : ');
for x:=1 to length(nm) do
write(data[x]);
writeln;
for x:=1 to length(nm)-1 do
begin
for y:=1 to length(nm)-x do
begin
if data[y] < data[y+1] then
begin
z:=data[y];
data[y]:=data[y+1];
data[y+1]:=z;
end;end;end;
write('Hasil Desending : ');
for x:=1 to length(nm) do
write(data[x]);writeln;
readln;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar