Advertisement
paulogp

Ordenacao de elementos

Aug 7th, 2011
170
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Pascal 0.84 KB | None | 0 0
  1. { paulogp }
  2. Program Ordena;
  3.  
  4. Uses
  5.     WinCrt;
  6.  
  7. Const
  8.     Max = 10; { Quantidade de Numeros }
  9.  
  10. Var
  11.     Valor: Array[1..Max] of Byte;
  12.     I, J, C: Integer;
  13.     Tecla: Char;
  14.  
  15. Begin
  16.     Repeat
  17.         ClrScr;
  18.         GotoXY(30, 2);
  19.         WriteLn('ORDENACAO DE ELEMENTOS');
  20.         GotoXY(30, 3);
  21.         WriteLn('~~~~~~~~~~~~~~~~~~~~~~');
  22.         WriteLn;
  23.         WriteLn('Introduza os valores [1,', Max,']: ');
  24.         For I:= 1 to Max do
  25.         Begin
  26.             Write('V[',I,']: ');
  27.             ReadLn(Valor[I]);
  28.         End;
  29.         { Ordena }
  30.         For I:= 2 to Max do
  31.             For J:= 1 to I-1 do
  32.                 If Valor[I] < Valor[J] then
  33.                 Begin
  34.                     C:= Valor[I];
  35.                     Valor[I]:= Valor[J];
  36.                     Valor[J]:= C;
  37.                 End;
  38.         { Escreve }
  39.         WriteLn;
  40.         WriteLn;
  41.         For I:= 1 to Max-1 do Write(Valor[I],',');
  42.         Write(Valor[Max],'.');
  43.         WriteLn;
  44.         WriteLn;
  45.         Write('Repetir (s/n): ');
  46.         Tecla:= ReadKey;
  47.     Until UpCase(Tecla) = 'N';
  48. End.
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement