uses
crt ;
var
nama
: array[1..3] of string ;
xnama
: string ;
jmldata : byte ;
i, j
: byte ;
begin
jmldata := 3 ;
for i := 1 to jmldata do
begin
write('Nama ke ',i,':') ;
readln(nama[i]) ;
end;
clrscr;
for i := 1 to jmldata do
begin
writeln ('Nama ke ',i,':', nama[i]) ;
end;
for i:= 1 to jmldata-1 do
begin
for j:= jmldata-1 downto i do
begin
if nama[j] > nama[j+1] then
begin
xnama := nama[j] ;
nama[j] := nama[j+1] ;
nama[j+1] := xnama ;
end;
end;
end;
writeln;
for i := 1 to 3 do
begin
writeln ('Nama ke ',i,':', nama[i]) ;
end;
readln;
end.Dan berikut output akhirnya :
Tidak ada komentar:
Posting Komentar