读取程序后程序停止(delphi) [英] program stops after reading procedure (delphi)

查看:81
本文介绍了读取程序后程序停止(delphi)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的程序停止读取所有行,并在此过程之后像其结束一样结束程序(但不是):

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.

这篇关于读取程序后程序停止(delphi)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆