I have to implement the insert sorting method in Pascal.
The problem is that in my algorithm I'm having to do multiple if
s. One for every possibility.
I wonder if there is a better way to do this.
My code:
Program insertion_sort ;
var
cont , aux : integer ;
numero : array[1..5] of integer ;
Begin
for cont := 1 to 5 do
begin
writeln('Digite um numero : ');
read(numero[cont]);
end;
for cont := 1 to 5 do
begin
if(numero[1] > numero[2]) then
begin
aux := numero[1] ;
numero[1] := numero[2] ;
numero[2] := aux;
end;
writeln(numero[cont]);
end;
End.