问题
My program stops to read anymore lines and ends the program after this procedure like its 'end.' after it (but its not) :
Procedure BubbleSort;
var i, j : integer;
begin
for i := 0 to count - 1 do begin
for j := count - 1 downto i do
if (together[j] > together[j - 1]) then
Swap(together[j - 1], together[j]);
end;
end;
回答1:
I guess the problem is the out of bounds array access. You access index -1. Avoid this by changing the outer loop to:
for i := 1 to count - 1 do begin
I suggest that you enable range checking so that you can learn about out of bounds array access by way of informative runtime errors.
来源:https://stackoverflow.com/questions/29594762/program-stops-after-reading-procedure-delphi