Program Binary_Searching;
uses crt;
const
n = 10;
var
data : array[1..n] of string[1];
nm, z : string;
item : char;
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 x:=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;
for x:=1 to length(nm) do;
write(' Character di cari : ');readln(item);
x:=1;
while(data[x] <> ' ') and (x<=n) do inc(x);
data[x]:=item;
loc:=1;
while (data[loc] <> item) and (loc<=x) do loc:=loc+1;
write(' Keterangan : ');
if loc = x then
write(' Huruf ',item,' tidak ditemukan')
else
write(' Huruf ',item,' ada di lokasi ',loc);
readln;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar