比如我现在有一个字符数组 mystr:=5,8,7,4,2 怎样把他从小到大排列成一个新的数组newstr(这个是数的数组,不是字符)??
解决方案 »
- 请问我为什么不能向数据库插入数据??
- 如何通过TabOrder的设定控制Button的Enable?
- help:delphi and access 插入大量數據時出錯。附帶一個orace字符串比較問題。
- 如何实现eval?
- 如何用delphi通过Twain.DLL调用扫描仪???急!!!
- 一个简单问题
- 关于DBCombobox的items的问题
- 兄弟们,帮帮忙呀
- 广东中山全通请delphi程序员,谁有兴趣
- 200分请解:用database desktop加密的数据表的解密方法
- 老问题,IE 中使用 activx 组件,怎么获得调用它的IWebBrowser2?
- 如何在Delphi調用Crystal Report報表設計器?
var i,j,temp:integer;
begin
for i := high(a) downto low(a) do
begin
for j := low(a) to i do
begin
if a[j]>a[j+1] then
begin
temp := a[j];
a[j] := a[j+1];
a[j+1] := temp;
end;
end;
end;
end;
我这样定义一个函数有问题吗?
为什么说[DCC Error] Unit1.pas(55): E2029 Identifier expected but 'ARRAY' found
我把array 改成tStringlist就可以了
但我想返回的类型是array
begin
dosomething...
end
procedure intSort(pi: PIntegerArray; Count: Integer); procedure QuickSort(L, R: Integer);
var
I, J, P: Integer;
Tmp: Integer;
begin
repeat
I := L;
J := R;
P := (L + R) shr 1;
repeat
while pi[I] < pi[P] do Inc(I); while pi[J] > pi[P] do Dec(J); if I <= J then
begin
//交换
Tmp := pi[I];
pi[I] := pi[J];
pi[J] := Tmp; if P = I then
P := J
else if P = J then
P := I;
Inc(I);
Dec(J);
end;
until I > J;
if L < J then QuickSort(L, J);
L := I;
until I >= R;
end;begin
QuickSort(0, Count - 1);
end;procedure TForm1.Button1Click(Sender: TObject);
var
a: array of Integer;
i: Integer;
begin
//设置数组大小
SetLength(a, 5); //初始化
a[0] := 5;
a[1] := 8;
a[2] := 7;
a[3] := 4;
a[4] := 2; //排序
intSort(@a[0], High(a) - Low(a) + 1); Memo1.Lines.Clear;
for i := 0 to High(a) do
Memo1.Lines.Add(IntToStr(a[i]));
end;
for i := high(a) downto low(a) do
这里改成你的》?