Program QuickSort_Sort_Array; Const Tam=10; Type Tipo_Vetor=Array[1..Tam] of Integer; Procedure Gera_Valores(Var V:Tipo_Vetor); Var cont:Integer; Begin For cont:=1 to Tam Do V[cont]:=random(Tam+1); End; Procedure Exibe_Valores(V:Tipo_Vetor); Var aux:integer; Begin for aux:=1 to Tam do begin write('V[',aux,']=',V[aux]); if aux <> Tam then write(', ') else writeln; end; End; Procedure QuickSort (Var V:Tipo_Vetor); Procedure Sort(Var V:Tipo_Vetor; ini,fim:Integer); Var i,j,x,aux:integer; Begin i:=ini; j:=fim; x:=V[(ini+fim) DIV 2]; repeat while V[i] < x do i:=i+1; while V[j] > x do j:=j-1; if i<=j then begin aux:=V[i]; V[i]:=V[j]; V[j]:=aux; i:=i+1; j:=j-1; end; until i > j; if ini < j then sort(v,ini,j); if i < fim then sort(v,i,fim); End; Begin sort(v,1,Tam); End; Var Vetor:Tipo_Vetor; Begin Writeln; Writeln('>> ORDENACAO DE VETORES <<'); Writeln; writeln('Metodo QuickSort'); Gera_Valores(Vetor); Exibe_Valores(Vetor); QuickSort(Vetor); Exibe_Valores(Vetor); readln; End.