program ordenar;
uses crt;
var
i, a, b, c, aux: integer;
begin
clrscr;
writeln('Escolha uma opcao');
writeln('1-Decrescente');
writeln('2- Crescente');
readln (i);
while (i<1) or (i>2) do
begin
clrscr;
writeln ('Op‡Æo invalida, insira novamente');
writeln('Escolha uma op‡Æo');
writeln('1-Decrescente');
writeln('2- Crescente');
readln (i);
end;
write('Informe o primeiro numero: ');
readln(a);
write('Informe o segundo numero: ');
readln(b);
write('Informe o terceiro numero: ');
readln(c);
if a>b then
begin
aux:=a;
a:=b;
b:=aux;
end;
if a>c then
begin
aux:=a;
a:=c;
c:=aux;
end;
if b>c then
begin
aux:=b;
b:=c;
c:=aux;
end;
if i=1 then
begin
writeln('Valores em ordem crescente: ', a:6, b:6, c:6);
end;
if i=2 then
begin
writeln('Valores em ordem decrescente: ', c:6, b:6, a:6);
end;
if i=3 then
begin
writeln('Maior Valor no meio: ', a:6, c:6, b:6);
end;
readkey;
end.