如何提高FOR的循环速度...(0分)

  • 主题发起人 主题发起人 why_119
  • 开始时间 开始时间
W

why_119

Unregistered / Unconfirmed
GUEST, unregistred user!
如何提高FOR的循环速度...
for a:=1 to length(xx1) do
begin
FOR b:=1 TO length(xx2) DO
BEGIN
FOR c:=1 TO length(xx3) DO
BEGIN
FOR d:=1 TO length(xx4) DO
BEGIN
FOR e:=1 TO length(xx5) DO
BEGIN
FOR f:=1 TO length(xx6) DO
BEGIN
FOR g:=1 TO length(xx7) DO
BEGIN
FOR h:=1 TO length(xx8) DO
BEGIN
FOR i:=1 TO length(xx9) DO
BEGIN
FOR j:=1 TO length(xx10) DO
BEGIN
FOR k:=1 TO length(xx11) DO
BEGIN
FOR l:=1 TO length(xx12) DO
BEGIN
FOR m:=1 TO length(xx13) DO
BEGIN
footballhm:=xx1[a]+xx2+xx3[c]+xx4[d]+xx5[e]+xx6[f]+xx7[g]+xx8[h]+xx9+xx10[j]+xx11[k]+xx12[l]+xx13[m];
richedit1.Lines.Add(footballhm);


END;END;END;END;END;END;END;END;END;END;END;END;
 
var
s: string;
...
s := '';
for a:=1 to length(xx1) do
begin
FOR b:=1 TO length(xx2) DO
BEGIN
FOR c:=1 TO length(xx3) DO
BEGIN
FOR d:=1 TO length(xx4) DO
BEGIN
FOR e:=1 TO length(xx5) DO
BEGIN
FOR f:=1 TO length(xx6) DO
BEGIN
FOR g:=1 TO length(xx7) DO
BEGIN
FOR h:=1 TO length(xx8) DO
BEGIN
FOR i:=1 TO length(xx9) DO
BEGIN
FOR j:=1 TO length(xx10) DO
BEGIN
FOR k:=1 TO length(xx11) DO
BEGIN
FOR l:=1 TO length(xx12) DO
BEGIN
FOR m:=1 TO length(xx13) DO
BEGIN
s:=s+xx1[a]+xx2+xx3[c]+xx4[d]+xx5[e]+xx6[f]+xx7[g]+xx8[h]+xx9+xx10[j]+xx11[k]+xx12[l]+xx13[m]+#13#10;
END;END;END;END;END;END;END;END;END;END;END;END;
richedit1.lines.text := s;
 
谢.我试一下...
 
不行.还是慢....
 
废话, 那么多层循环嵌套不可能快. 关键是你的算法有问题.
 
呵呵 教训得是 .. CPU 时间都花在控制循环上面了 [:D]
 
怎么写能快点...
 
后退
顶部