To all:这是一个数据库程序,设置标志我觉得不可行,设置标志还是避免不了比较;
To yangkunjie(杨七郎(dephi--c#)):我觉得你说的直接从中抽走的办法比较好,这样就不必去比较了,非常感谢!
To yangkunjie(杨七郎(dephi--c#)):我觉得你说的直接从中抽走的办法比较好,这样就不必去比较了,非常感谢!
解决方案 »
- 高分求解决方案!为何在查询分析器中运行很快但在ADOQUERY打开却很慢???
- 我的机器装了Sygate,可正常上网,但是QQ,PP等东东不能登陆,是哪儿的事?
- 在线等待,如何实现Table.Filter的模糊查询?
- 关于binary类型(sql server)
- 请教用delphi的Tquery控件处理oracle数据库的问题
- 一个简单问题!!————如何编写双重查询!---在线等候!
- 请指点,很简单的问题,为什么没人回答我呀,我都问第三遍了!分少就没人理了么!
- 如何取得装操作系统时取的公司名称和用户名?我是菜鸟。
- 如何用DELPHI程序制作自己的拨号网络服务器(控制MODEM)?
- 追捕的数据包是什么格式的??? 就是那个wry.dll ??
- 怎麼寫delphi語句把word/excel/bmp等文件存入Oracle中的blob字段里去??
- 关于数据对齐问题
一般的方法都是2个for循环、而我的程序只要1个for循环,速度大大的提高拉
Dest: array[1..20000] of Integer;
Source: array[1..100000] of Integer;
I, J, T: Integer;
MaxIndex: Integer;
begin
Randomize;
MaxIndex := 100000;
for I := 1 to 20000 do begin
J := Random(MaxIndex) + 1;
T := Source[J];
Source[J] := Source[MaxIndex];
Source[MaxIndex] := T;
Dest[I] := T;
Dec(MaxIndex);
end;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Memo1: TMemo;
Button2: TButton;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;var
Form1: TForm1;
x:array[0..999999] of boolean;
y:array[0..19999] of integer;implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var i,z:integer;
begin
i:=0;
while i<20000 do begin
z:=random(999999);
if not x[z] then begin
y[i]:=z;
i:=i+1; end;
end;
showmessage('OK!')end;procedure TForm1.Button2Click(Sender: TObject);
var i:integer;
begin
memo1.Clear;
for i:=0 to 19999 do memo1.Lines.Add(inttostr(y[i]));
end;end.
半秒算出来!
请问你这是什么意思
if not x[z] then begin
y[i]:=z;
i:=i+1;
end;别人要的是在100000个数中找出一个都不相同的20000个数
放到另一个数组中
你的 not x[z]要是z随机的时候重复了怎么办...我写一秒不到是正确的.
你的答案是错误的.