Program Character_Binary;
uses crt;
var
data : array [1..10] of string[1];
nama : string;
z : string;
item : char;
Loc, x, y : integer;
begin
clrscr;
write(' Nama Mahasiswa : ');readln(nama);
for x:=1 to length(nama) do
data[x]:=copy(nama,x,1);
for x:=1 to length(nama)-1 do
begin
for y:=1 to length(nama)-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(nama) do
write(data[x]);writeln;
write(' Character yang dicari : ');readln(item);
writeln(' Keterangan : ');
Loc:=0;
for x:=1 to length(nama) do
begin
loc:=loc+1;
if data[x] = item then
writeln(' ',item,' ada di posisi ke- ', loc)
end;
x:=1;
if loc = x then
writeln (' Character ',item,' tidak ada');
readln;
end.
Langganan:
Posting Komentar (Atom)
Tidak ada komentar:
Posting Komentar