Olá pessoal, tudo beleza?
seguinte.. to fazendo uma ordenação por shellsort, compila normal sem zica..
mais quando ele entra na procedure ta dando runtime error..
segue o cod abaixo, da uma força ae pessoal ;D
program shell_sort; Uses CRT; Const N=5; Type Tp_Vetor = array [1..N] of integer; Var Vetor:Tp_Vetor; i:integer; //----------------------------------------------------------------------------------- Procedure ShellSort (Vetor:Tp_Vetor); Var fim, indice,indice2, aux, posicao:integer; Begin Dist := (N Div 2)+1; fim:= N - Dist; Posicao:=Dist; For indice:=dist downto 1 do Begin For indice2:=1 to fim do Begin If(Vetor[indice2] <= Vetor[posicao]) then Begin posicao:=posicao + 1; end Else Begin aux:= Vetor[posicao]; vetor[posicao]:=Vetor[indice]; Vetor[indice]:= aux; posicao:=posicao+1; end; end; end; end; //------------------------------------------------------------------------------------- Begin CLRSCR; Writeln('Vetor a ser verificado'); randomize; For I:=1 to N do Begin Vetor[i]:= random(100); Write(Vetor[i], ' | '); end; Writeln(''); Shellsort(Vetor); Writeln('Vetor ordenado'); For i:=1 to N do Begin Write(vetor[i], ' | '); end; Readln; end.