program ordenar(input, output);
uses crt, dos;
const Max = 6;
var vector: array[1..max] of string;
i, inic: integer;
temp: string;
ch: char;
Procedure ler;
var i: integer;
begin
For i:= 1 to max do
begin
write('Digite o ',i, ' nome: ');
Readln (vector[i]);
end;
end;
Procedure listar;
begin
clrscr;
writeln('Dados ordenados por ordem ascendente.');
for i:= 1 to max do
begin
writeln(vector[i])
end;
readln;
end;
Procedure ordem_ascendente;
begin
for inic:=1 to (max-1) do
begin
for i:=(inic+1) to max do
begin
if (vector[i]) < (vector[inic]) then
begin
temp:= vector[inic];
vector[inic]:= vector[i];
vector[i]:= temp;
end;
end;
end;
listar;
end;
Procedure ordem_descendente;
begin
for inic:=1 to (max-1) do
begin
for i:=(inic+1) to max do
begin
if (vector[i]) > (vector[inic]) then
begin
temp:= vector[inic];
vector[inic]:= vector[i];
vector[i]:= temp;
end;
end;
end;
listar;
end;
begin {programa principal}
repeat
clrscr;
writeln('1 - Introduzir dados');
writeln('2 - Ordenar por ordem ascendente');
writeln('3 - Ordenar por ordem descendente');
writeln('4 - Sair');
Ch:=ReadKey;
case Ch of
'1': ler;
'2': ordem_ascendente;
'3': ordem_descendente;
end;
until (ch='4')
end.