|
马上注册,结交更多好友,享用更多功能^_^
您需要 登录 才可以下载或查看,没有账号?立即注册
x
各位前辈高手,写了个数值计算程序,发现输入的数值过大就会出错或程序卡死,请问是什么原因?(见附件程序及源码)
附上源码:
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;
type
TForm1 = class(TForm)
Edit1: TEdit;
Label1: TLabel;
Label2: TLabel;
Edit2: TEdit;
Button1: TButton;
Label3: TLabel;
Edit3: TEdit;
Edit4: TEdit;
Label4: TLabel;
Label5: TLabel;
Edit5: TEdit;
Edit6: TEdit;
Edit7: TEdit;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.dfm}
procedure TForm1.Button1Click(Sender: TObject);
var
Num:Array of Integer;
sl,s,i,max,max_i:Integer;
begin
sl:=StrToInt(Edit2.text);
s:=StrToInt(Edit1.Text);
SetLength(Num,sl);
For i:=1 to sl do
begin
Edit4.Text:=Edit4.Text+IntToStr(s)+',';
Num[i]:=s;
s:=s+1;
While( Pos(Edit3.Text,IntToStr(s)) >0 ) do //Pos:取出子串在父串中第一次出现的位置
begin
s:=s+1;
end;
While( Pos(Edit7.Text,IntToStr(s)) >0 ) do //Pos:取出子串在父串中第一次出现的位置
begin
s:=s+1;
end;
end;
max:=Num[1];
max_i:=1;
For i:=2 to sl do
begin
If (max < Num[i]) then
begin
max:=Num[i];
max_i:=i;
end;
Edit5.Text:=IntToStr(max);
Edit6.Text:=IntToStr(max_i);
end;
end;
end. |
|