荒
荒草地
Unregistered / Unconfirmed
GUEST, unregistred user!
unit Unit1;
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
k,i,x,y,tmp:integer;
m : array[1..7] of integer;
label label1;
begin
label1:
for x := 1 to 7 do
begin
m[x] := 0;
end;
tmp := 0;
Randomize;
for x := 1 to 7 do
begin
sleep(x);
m[x] := Random(36);
if x > 1 then
begin
for i := 1 to (x-1) do
begin
if (m[x] = m) then
begin
goto label1;
end;
end;
end;
end;
for x := 1 to 7 do
begin
for y := 1 to (7-x) do
begin
if m[y] > m[y+1] then
tmp := m[y];
m[y] := m[y+1];
m[y+1] := tmp;
end;
end;
Label2.Caption := IntToStr(m[1]);
Label3.Caption := IntToStr(m[2]);
Label4.Caption := IntToStr(m[3]);
Label5.Caption := IntToStr(m[4]);
Label6.Caption := IntToStr(m[5]);
Label7.Caption := IntToStr(m[6]);
Label8.Caption := IntToStr(m[7]);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label2.Caption := IntToStr(0);
Label3.Caption := IntToStr(0);
Label4.Caption := IntToStr(0);
Label5.Caption := IntToStr(0);
Label6.Caption := IntToStr(0);
Label7.Caption := IntToStr(0);
Label8.Caption := IntToStr(0);
end;
end.
得到的数字为何一直存在重复的?费解
interface
uses
Windows, Messages, SysUtils, Classes, Graphics, Controls, Forms, Dialogs,
StdCtrls;
type
TForm1 = class(TForm)
Label1: TLabel;
Label2: TLabel;
Button1: TButton;
Button2: TButton;
Label3: TLabel;
Label4: TLabel;
Label5: TLabel;
Label6: TLabel;
Label7: TLabel;
Label8: TLabel;
procedure Button1Click(Sender: TObject);
procedure Button2Click(Sender: TObject);
procedure FormCreate(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
end;
var
Form1: TForm1;
implementation
{$R *.DFM}
procedure TForm1.Button1Click(Sender: TObject);
var
k,i,x,y,tmp:integer;
m : array[1..7] of integer;
label label1;
begin
label1:
for x := 1 to 7 do
begin
m[x] := 0;
end;
tmp := 0;
Randomize;
for x := 1 to 7 do
begin
sleep(x);
m[x] := Random(36);
if x > 1 then
begin
for i := 1 to (x-1) do
begin
if (m[x] = m) then
begin
goto label1;
end;
end;
end;
end;
for x := 1 to 7 do
begin
for y := 1 to (7-x) do
begin
if m[y] > m[y+1] then
tmp := m[y];
m[y] := m[y+1];
m[y+1] := tmp;
end;
end;
Label2.Caption := IntToStr(m[1]);
Label3.Caption := IntToStr(m[2]);
Label4.Caption := IntToStr(m[3]);
Label5.Caption := IntToStr(m[4]);
Label6.Caption := IntToStr(m[5]);
Label7.Caption := IntToStr(m[6]);
Label8.Caption := IntToStr(m[7]);
end;
procedure TForm1.Button2Click(Sender: TObject);
begin
close;
end;
procedure TForm1.FormCreate(Sender: TObject);
begin
Label2.Caption := IntToStr(0);
Label3.Caption := IntToStr(0);
Label4.Caption := IntToStr(0);
Label5.Caption := IntToStr(0);
Label6.Caption := IntToStr(0);
Label7.Caption := IntToStr(0);
Label8.Caption := IntToStr(0);
end;
end.
得到的数字为何一直存在重复的?费解