我刚写的!通过! procedure TForm1.Button1Click(Sender: TObject); var aa:array [1..10] of integer; sult:integer; i:integer; begin Randomize; //先随机给个数字 sult:=Random(100); I:=1; aa[i]:=sult; for i:=2 to 10 do begin sult:=Random(100); Repeat sult:=Random(100); Until sult<>aa[i-1]; aa[i]:=sult; showmessage(inttostr(sult)); end; end;
function gettennummber:string; var i:Integer; ntmp:integer; begin Randomize; ntmp:=0; i:=0; Result:=''; While i<10 do begin ntmp:=RandomRange(1,100); if Pos(Inttostr(ntmp),Result)>0 then continue else begin Result:=Result+IntToStr(ntmp)+','; inc(i,1); end; end;end;
procedure TForm1.Button1Click(Sender: TObject); var aa:array [1..10] of integer; sult,i,j,k:integer; s:string; begin k:=0; Randomize; //先随机给个数字 sult:=Random(100); i:=1; aa[i]:=sult; while i<=10 do begin sult:=Random(100); for j:=1 to i do begin if sult<>aa[j] then begin k:=k+1; continue end; end; if (k=i)then begin aa[i+1]:=sult; i:=i+1; end; k:=0; end; for j:=1 to 10 do edit1.Text :=edit1.Text +' '+(inttostr(aa[j])); end; procedure TForm1.Button2Click(Sender: TObject); begin edit1.Text :=''; end;啊!!!!俺来晚了!! 不好意思:( 我刚才在做点事,所以晚了:( 试试吧,是成功的,显示在EDIT1中,两个按钮,一个是显示,一个是清空
procedure TForm1.Button1Click(Sender: TObject);
var
aa:array [1..10] of integer;
sult:integer;
i:integer;
begin
Randomize;
//先随机给个数字
sult:=Random(100);
I:=1;
aa[i]:=sult; for i:=2 to 10 do
begin
sult:=Random(100);
Repeat
sult:=Random(100);
Until sult<>aa[i-1];
aa[i]:=sult; showmessage(inttostr(sult));
end;
end;
var
i:Integer;
ntmp:integer;
begin
Randomize;
ntmp:=0;
i:=0;
Result:='';
While i<10 do
begin
ntmp:=RandomRange(1,100);
if Pos(Inttostr(ntmp),Result)>0 then
continue
else
begin
Result:=Result+IntToStr(ntmp)+',';
inc(i,1);
end;
end;end;
var
aa:array [1..10] of integer;
sult,i,j,k:integer;
s:string;
begin
k:=0;
Randomize;
//先随机给个数字
sult:=Random(100);
i:=1;
aa[i]:=sult; while i<=10 do
begin
sult:=Random(100);
for j:=1 to i do
begin
if sult<>aa[j] then
begin
k:=k+1;
continue
end;
end; if (k=i)then
begin
aa[i+1]:=sult;
i:=i+1;
end;
k:=0;
end;
for j:=1 to 10 do
edit1.Text :=edit1.Text +' '+(inttostr(aa[j]));
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
edit1.Text :='';
end;啊!!!!俺来晚了!!
不好意思:(
我刚才在做点事,所以晚了:(
试试吧,是成功的,显示在EDIT1中,两个按钮,一个是显示,一个是清空