今天做一个程序时,无意当中发现这个问题。
新建一个工程。一个Button,代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
inttmp,inttemp:integer;
strtmp:string;
intt:array [0..99] of array [0..99] of integer;
begin
inttotal:=0;
for inttmp:=0 to 99 do
begin
for inttemp:=0 to 99 do
begin
// intt[inttmp][inttemp]:=inttmp*inttemp;
intt[inttmp][inttemp]:=random(10);
inttotal:=inttotal+1;
end;
end;end;
其中inttotal为全局变量。这个时候 inttmp和inttemp竟然是从100到0倒着排。
把现在注释的语句加进来才从0开始。
目前来看这个应该是Delphi本身的代码优化问题。
我想问这样会不会对程序结果产生错误的影响。
就算是优化,为什么非要递减哪?减法不是比加法复杂吗?
希望高手能够告知!
新建一个工程。一个Button,代码如下:
procedure TForm1.Button1Click(Sender: TObject);
var
inttmp,inttemp:integer;
strtmp:string;
intt:array [0..99] of array [0..99] of integer;
begin
inttotal:=0;
for inttmp:=0 to 99 do
begin
for inttemp:=0 to 99 do
begin
// intt[inttmp][inttemp]:=inttmp*inttemp;
intt[inttmp][inttemp]:=random(10);
inttotal:=inttotal+1;
end;
end;end;
其中inttotal为全局变量。这个时候 inttmp和inttemp竟然是从100到0倒着排。
把现在注释的语句加进来才从0开始。
目前来看这个应该是Delphi本身的代码优化问题。
我想问这样会不会对程序结果产生错误的影响。
就算是优化,为什么非要递减哪?减法不是比加法复杂吗?
希望高手能够告知!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货