implementation{$R *.dfm}procedure TForm1.Button1Click(Sender: TObject);
var
a:array[1..10] of integer;
i,j:integer;
swap:integer;
begin
edit1.Clear;
a[1]:=56;
a[2]:=23;
a[3]:=5;
a[4]:=76;
a[5]:=16;
a[6]:=96;
a[7]:=51;
a[8]:=43;
a[9]:=18;
a[10]:=38;
i:=10 div 2;
while(i>=1) do
begin
swap:=a[i];
j:=i*2;
while(j<=10) do
begin
if a[j]<a[j+1] then
j:=j+1;
if a[j]<swap then
break;
a[i]:=a[j];
i:=j;
j:=j*2;
end;
a[i]:=swap;
i:=i-1;
end;
for i:=1 to 10 do
edit1.Text:=edit1.Text+' '+inttostr(a[i]); //当把这一行去掉之后就没事了,但不能显示筛选侯的数组了。
end;end.
编译可以通过,但是一运行的话就会出现错误。
我感觉好像就不能输出筛选后的数组,显示其中一个好像也不行。
var
a:array[1..10] of integer;
i,j:integer;
swap:integer;
begin
edit1.Clear;
a[1]:=56;
a[2]:=23;
a[3]:=5;
a[4]:=76;
a[5]:=16;
a[6]:=96;
a[7]:=51;
a[8]:=43;
a[9]:=18;
a[10]:=38;
i:=10 div 2;
while(i>=1) do
begin
swap:=a[i];
j:=i*2;
while(j<=10) do
begin
if a[j]<a[j+1] then
j:=j+1;
if a[j]<swap then
break;
a[i]:=a[j];
i:=j;
j:=j*2;
end;
a[i]:=swap;
i:=i-1;
end;
for i:=1 to 10 do
edit1.Text:=edit1.Text+' '+inttostr(a[i]); //当把这一行去掉之后就没事了,但不能显示筛选侯的数组了。
end;end.
编译可以通过,但是一运行的话就会出现错误。
我感觉好像就不能输出筛选后的数组,显示其中一个好像也不行。
解决方案 »
- 诚心求教,QuickReport 控件,打印预览时页面位置整体上移或者下移的方法!
- expressprinting system控件
- SHELLEXEC()在这里怎么不能运行?帮我看看.谢谢.
- ADOQuery执行的问题,在线等待,马上给分
- treeview+access 小问题
- 从一个表中查询出结果,并写到另一个表中的程序,这样写对吗?请高手过招,给分。
- 如何 组合快捷键 如ALT+X Ctrl+1,2,3...?在线,既答既送!!!
- 有没有能拖出成浮动小窗口的TToolbar 控件?
- delphi更新sysbase数据库求助!!!
- 快看zswang有好大一条虫(函数Calc)
- maskedit的值怎么读取出来?
- 谁给个Delphi下载地址
var
s:string;.....
s:='';
for i:=1 to 10 do
s:=s+inttostr(a[i]);
edit1.text:=s;
s:string;
.....
s:='';
for i:=1 to 10 do
s:=s+' '+inttostr(a[i]);
edit1.text:=s;
a: array of integer;
{这样设长度} setlength(a,10);
{这样取值} for i :=1 to High(a) do
begin
ListBox1.Items.Add(inttostr(a[i]))
end;
以下的你就要检查一下:i:=10 div 2;
while(i>=1) do
begin
swap:=a[i];
j:=i*2;
while(j <=10) do
begin
if a[j] <a[j+1] then
j:=j+1;
if a[j] <swap then
break;
a[i]:=a[j];
i:=j;
j:=j*2;
end;
a[i]:=swap;
i:=i-1;
end;
s:string;
.....
s:='';
for i:=1 to 10 do
s:=s+' '+inttostr(a[i]);
edit1.text:=s;
a: array of integer;
{这样设长度} setlength(a,10);
{这样取值} for i :=1 to High(a) do
begin
ListBox1.Items.Add(inttostr(a[i]))
end;
以下的你就要检查一下:i:=10 div 2;
while(i>=1) do
begin
swap:=a[i];
j:=i*2;
while(j <=10) do
begin
if a[j] <a[j+1] then
j:=j+1;
if a[j] <swap then
break;
a[i]:=a[j];
i:=j;
j:=j*2;
end;
a[i]:=swap;
i:=i-1;
end;
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure Sort(var A:array of integer);
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.Sort(var A:array of integer);
var
i,j,t:integer;
begin
for i:=low(A) to High(A)-1 do
for j:=High(A) downto i+1 do
if A[i]>A[j] then
begin
t:=A[i];A[i]:=A[j];A[j]:=t;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a: array of integer;
i,j,l:integer;
swap:integer;
begin
setlength(a,10);
a[0]:=56;
a[1]:=23;
a[2]:=5;
a[3]:=76;
a[4]:=16;
a[5]:=96;
a[6]:=51;
a[7]:=43;
a[8]:=18;
a[9]:=38; Sort(a); for l :=0 to 9 do
begin
ListBox1.Items.Add(inttostr(a[l]))
end;
a:=nil;end;
end.
[code=Delphi(Pascal)]
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure Sort(var A:array of integer);
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.Sort(var A:array of integer);
var
i,j,t:integer;
begin
for i:=low(A) to High(A)-1 do
for j:=High(A) downto i+1 do
if A[i]>A[j] then
begin
t:=A[i];A[i]:=A[j];A[j]:=t;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a: array of integer;
i,j,l:integer;
swap:integer;
begin
setlength(a,10);
a[0]:=56;
a[1]:=23;
a[2]:=5;
a[3]:=76;
a[4]:=16;
a[5]:=96;
a[6]:=51;
a[7]:=43;
a[8]:=18;
a[9]:=38; Sort(a); for l :=0 to 9 do
begin
ListBox1.Items.Add(inttostr(a[l]))
end;
a:=nil;
end;
end.
[/code]
[code=Delphi(Pascal)]
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
public
{ Public declarations }
procedure Sort(var A:array of integer);
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.Sort(var A:array of integer);
var
i,j,t:integer;
begin
for i:=low(A) to High(A)-1 do
for j:=High(A) downto i+1 do
if A[i]>A[j] then
begin
t:=A[i];A[i]:=A[j];A[j]:=t;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a: array of integer;
i,j,l:integer;
swap:integer;
begin
setlength(a,10);
a[0]:=56;
a[1]:=23;
a[2]:=5;
a[3]:=76;
a[4]:=16;
a[5]:=96;
a[6]:=51;
a[7]:=43;
a[8]:=18;
a[9]:=38; Sort(a); for l :=0 to 9 do
begin
ListBox1.Items.Add(inttostr(a[l]))
end;
a:=nil;
end;
end.
[/code]
i:=10 div 2;
while(i>=1) do
begin
swap:=a[i];
j:=i*2; //I为5
while(j <=10) do
begin
if a[j] <a[j+1] then
j:=j+1; //J 为11了,越界了
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure lSort(var A:array of integer);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.lSort(var A:array of integer);
var
i,j,t:integer;
begin
for i:=low(A) to High(A)-1 do
for j:=High(A) downto i+1 do
if A[i]>A[j] then
begin
t:=A[i];A[i]:=A[j];A[j]:=t;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a:array of integer;
i:integer;
s1: TStringList;
begin
SetLength(a,10);{指定长度}
edit1.Clear;
s1:=TStringList.Create;
a[0]:=56;
a[1]:=23;
a[2]:=5;
a[3]:=76;
a[4]:=16;
a[5]:=96;
a[6]:=51;
a[7]:=43;
a[8]:=18;
a[9]:=38;
lSort(a);{-------------------排序}
for i := 0 to 9 do
s1.Add(inttostr(a[i]));
edit1.Text:=s1.Strings[s1.Count-1]; {得到最大值}
a:=nil;
end;end.
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure lSort(var A:array of integer);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.lSort(var A:array of integer);
var
i,j,t:integer;
begin
for i:=low(A) to High(A)-1 do
for j:=High(A) downto i+1 do
if A[i]>A[j] then
begin
t:=A[i];A[i]:=A[j];A[j]:=t;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a:array of integer;
i:integer;
s1: TStringList;
begin
SetLength(a,10);{指定长度}
edit1.Clear;
s1:=TStringList.Create;
a[0]:=56;
a[1]:=23;
a[2]:=5;
a[3]:=76;
a[4]:=16;
a[5]:=96;
a[6]:=51;
a[7]:=43;
a[8]:=18;
a[9]:=38;
lSort(a);{-------------------排序}
for i := 0 to 9 do
s1.Add(inttostr(a[i]));
edit1.Text:=s1.Strings[s1.Count-1]; {得到最大值}
a:=nil;
end;end.
[code=Delphi(Pascal)]
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure lSort(var A:array of integer);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.lSort(var A:array of integer);
var
i,j,t:integer;
begin
for i:=low(A) to High(A)-1 do
for j:=High(A) downto i+1 do
if A[i]>A[j] then
begin
t:=A[i];A[i]:=A[j];A[j]:=t;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a:array of integer;
i:integer;
s1: TStringList;
begin
SetLength(a,10);{指定长度}
edit1.Clear;
s1:=TStringList.Create;
a[0]:=56;
a[1]:=23;
a[2]:=5;
a[3]:=76;
a[4]:=16;
a[5]:=96;
a[6]:=51;
a[7]:=43;
a[8]:=18;
a[9]:=38;
lSort(a);{-------------------排序}
for i := 0 to 9 do
s1.Add(inttostr(a[i]));
edit1.Text:=s1.Strings[s1.Count-1]; {得到最大值}
a:=nil;
end;end.
[/code]
[code=Delphi(Pascal)]
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure lSort(var A:array of integer);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.lSort(var A:array of integer);
var
i,j,t:integer;
begin
for i:=low(A) to High(A)-1 do
for j:=High(A) downto i+1 do
if A[i]>A[j] then
begin
t:=A[i];A[i]:=A[j];A[j]:=t;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a:array of integer;
i:integer;
s1: TStringList;
begin
SetLength(a,10);{指定长度}
edit1.Clear;
s1:=TStringList.Create;
a[0]:=56;
a[1]:=23;
a[2]:=5;
a[3]:=76;
a[4]:=16;
a[5]:=96;
a[6]:=51;
a[7]:=43;
a[8]:=18;
a[9]:=38;
lSort(a);{-------------------排序}
for i := 0 to 9 do
s1.Add(inttostr(a[i]));
edit1.Text:=s1.Strings[s1.Count-1]; {得到最大值}
a:=nil;
end;end.
[/code]
unit Unit1;interfaceuses
Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms,
Dialogs, StdCtrls;type
TForm1 = class(TForm)
Button1: TButton;
Edit1: TEdit;
ListBox1: TListBox;
procedure Button1Click(Sender: TObject);
private
{ Private declarations }
procedure lSort(var A:array of integer);
public
{ Public declarations }
end;var
Form1: TForm1;implementation{$R *.dfm}
procedure TForm1.lSort(var A:array of integer);
var
i,j,t:integer;
begin
for i:=low(A) to High(A)-1 do
for j:=High(A) downto i+1 do
if A[i]>A[j] then
begin
t:=A[i];A[i]:=A[j];A[j]:=t;
end;
end;procedure TForm1.Button1Click(Sender: TObject);
var
a:array of integer;
i:integer;
s1: TStringList;
begin
SetLength(a,10);{指定长度}
edit1.Clear;
s1:=TStringList.Create;
a[0]:=56;
a[1]:=23;
a[2]:=5;
a[3]:=76;
a[4]:=16;
a[5]:=96;
a[6]:=51;
a[7]:=43;
a[8]:=18;
a[9]:=38;
lSort(a);{-------------------排序}
for i := 0 to 9 do
s1.Add(inttostr(a[i]));
edit1.Text:=s1.Strings[s1.Count-1]; {得到最大值}
a:=nil;
end;end.
var
a:array of integer;
i:integer;
begin
SetLength(a,10);{指定长度}
edit1.Clear;
s1:=TStringList.Create;
a[0]:=56;
a[1]:=23;
a[2]:=5;
a[3]:=76;
a[4]:=16;
a[5]:=96;
a[6]:=51;
a[7]:=43;
a[8]:=18;
a[9]:=38;
lSort(a);
edit1.Text:=inttostr(a[9]);{得到最大值}
a:=nil;
end;