亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? sort1.pas

?? Quick Sort 算法將 ListBox 內容排序的范例
?? PAS
字號:
{*************************************************************************
* This is a small example application which demonstrates the use of
* the QSort procedure to sort the contents of a Listbox.
*
* Developed Oct 95 by Barry Schlereth
*
*                  ??? WHY ???
*
* The sorted parameter of a Listbox is nice, but what if you want to
* sort the strings by their numerical representation not alphabetically?
* Or, maybe you have a table and you would like to sort the rows of the
* table according to the floating point numbers displayed in one column.
*
* That is what this example shows. I hope you find it useful.
*
* This example can be freely distributed. Be sure to follow the
* copyrights shown below.
*
*
* If you feel very appreciative, a small donation - 1 dollar or a couple
* cereal coupons (Special K, Corn Flakes, Cheerios) - may be sent to:
*
*     Barry
*     Box 176
*     Syracuse, NY  13215
*
*************************************************************************}

unit Sort1;

interface

uses
  SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
  Forms, Dialogs, StdCtrls;

type
  TForm1 = class(TForm)
    DataBox1: TListBox;
    DataBox2: TListBox;
    BtnSort: TButton;
    BtnInit: TButton;
    Label1: TLabel;
    Label2: TLabel;
    BtnQSort: TButton;
    EdPts: TEdit;
    Label3: TLabel;
    Label4: TLabel;
    procedure BtnInitClick(Sender: TObject);
    procedure BtnSortClick(Sender: TObject);
    procedure BtnQSortClick(Sender: TObject);
  private
    { Private declarations }
  public
    { Public declarations }
  end;

var
  Form1: TForm1;

  procedure QSort(var a: array of Integer; const lo0, hi0: Integer);
  function Compare (const i, j: Integer) : Integer;

implementation

{$R *.DFM}

procedure TForm1.BtnInitClick(Sender: TObject);
var
  i : Integer;
  f : Single;
begin
  Label4.Caption := 'Initializing';
  Application.ProcessMessages;

  DataBox1.Items.Clear;
  DataBox2.Items.Clear;
  DataBox1.Sorted := False;
  DataBox2.Sorted := False;
  Application.ProcessMessages;

  if (StrToInt(EdPts.Text) > 5000) then begin
    EdPts.Text := '5000';
    Application.ProcessMessages;
  end;

  for i:=StrToInt(EdPts.Text) downto 1 do begin
    f := i;
    DataBox1.Items.Add(FloatToStrF(f, ffFixed, 10, 1));
  end;

  BtnSort.Enabled := True;
  BtnQSort.Enabled := True;

  Label4.Caption := '';
end;

procedure TForm1.BtnSortClick(Sender: TObject);
begin
  Label4.Caption := 'Copying';
  Application.ProcessMessages;
  DataBox2.Items.Clear;
  DataBox2.Sorted := False;
  DataBox2.Items.AddStrings(DataBox1.Items);

  Label4.Caption := 'Sorting';
  Application.ProcessMessages;
  DataBox2.Sorted := True;

  Label4.Caption := '';
end;

procedure TForm1.BtnQSortClick(Sender: TObject);
type
  IdxArray = array [0..4999] of Integer;
Var
  idx : ^IdxArray;
  i, n : Integer;
begin
  Label4.Caption := 'Initialize';
  Application.ProcessMessages;

  DataBox2.Items.Clear;
  DataBox2.Sorted := False;
  Application.ProcessMessages;

  New(idx);

  n := DataBox1.Items.Count;

  for i:=0 to n-1 do Idx^[i] := i;

  Label4.Caption := 'Quick Sort';
  Application.ProcessMessages;

  QSort(Idx^, 0, n-1);

  Label4.Caption := 'Display';
  Application.ProcessMessages;

  for i := 0 to n-1 do
    DataBox2.Items.Add(DataBox1.Items[Idx^[i]]);
  Application.ProcessMessages;

  Dispose(Idx);

  Label4.Caption := '';
end;

{********************************************************************
* QSort - Quick Sort
* Adapted for Delphi Pascal by Barry Schlereth   Oct 95
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice and the
* original copyright appears in all copies. (Also see below)
*
* THIS SOURCE CODE IS SUPPLIED "AS IS" AND IS NOT WARRANTIED IN ANY
* WAY, EXPRESS OR IMPLIED.
*
* Original "C" implementation by James Gosling (see below)
*
* The QSort procedure takes three parameters:
*   a   - an integer array of indices.
*   lo0 - the lower index of a to sort.
*   hi0 - the top index of a to sort (Count of a -1)
*
* Qsort requires a companion function, Compare(i, j), which tells
* it how to sort the indices. Compare returns -1, 0, +1, (<, =, >)
* depending on the relationship of a[i] to a[j]. In this example
* Compare(i, j) compares the StrToFloat of Item[i] to Item[j] in
* the ListBox (DataBox1).
*
* QSort is recursive - watch your stack when sorting large arrays.
*
*-----------------------------------------------------------------
* Quick Sort Algorithm
* original implementation by James Gosling v1.6 95/01/31
*
* Copyright (c) 1994 Sun Microsystems, Inc. All Rights Reserved.
*
* Permission to use, copy, modify, and distribute this software
* and its documentation for NON-COMMERCIAL purposes and without
* fee is hereby granted provided that this copyright notice
* appears in all copies. Please refer to the file "copyright.html"
* for further important copyright and licensing information.
*
* SUN MAKES NO REPRESENTATIONS OR WARRANTIES ABOUT THE SUITABILITY OF
* THE SOFTWARE, EITHER EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
* TO THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
* PARTICULAR PURPOSE, OR NON-INFRINGEMENT. SUN SHALL NOT BE LIABLE FOR
* ANY DAMAGES SUFFERED BY LICENSEE AS A RESULT OF USING, MODIFYING OR
* DISTRIBUTING THIS SOFTWARE OR ITS DERIVATIVES.
*---------------------------------------------------------------------}

procedure QSort(var a: array of Integer; const lo0, hi0: Integer);
var
  lo, hi, mid, t : Integer;
begin
  lo := lo0;
  hi := hi0;
  Application.ProcessMessages;

  if (lo < hi) then begin
    mid := (lo + hi) div 2;

    while (lo < hi) do begin
      while ((lo<hi) and (Compare(a[lo], a[mid]) < 0)) do inc(lo);

      while ((lo<hi) and (Compare(a[hi], a[mid]) > 0)) do dec(hi);

      if (lo < hi) then begin
        t := a[lo];
        a[lo] := a[hi];
        a[hi] := t;
      end;
    end;

    if (hi < lo) then begin
      t := hi;
      hi := lo;
      lo := t;
    end;

    QSort(a, lo0, lo);
    if (lo = lo0) then t := lo+1 else t := lo;
    QSort(a, t, hi0);
  end;
end;

{ This is the companion function Compare. It provides the relationship
  comparison for QSort. The indicies (i, j) can index into any type of
  Array, StringList, etc. In real-life you would speed things alot by
  by building and sorting a dummy floating point array derived from
the
  values in DataBox1.Items instead of converting with each comparison
  as is shown in this example! }

function Compare (const i, j: Integer) : Integer;
var
  f, g : Single;
begin
  f := StrToFloat(Form1.DataBox1.Items[i]);
  g := StrToFloat(Form1.DataBox1.Items[j]);

  if (f < g) then Compare := -1
  else if (f > g) then Compare := 1
  else Compare := 0;
end;

end.




?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产91在线观看丝袜| 亚洲妇女屁股眼交7| 国产成人av影院| 久久久久久久电影| 国产精品88888| 中文字幕一区二区5566日韩| 成人黄动漫网站免费app| 亚洲人123区| 欧美日韩国产成人在线免费| 蜜臀av亚洲一区中文字幕| 日韩免费观看高清完整版 | 51精品久久久久久久蜜臀| 日本午夜精品视频在线观看| 亚洲精品在线三区| 成人黄色国产精品网站大全在线免费观看| 婷婷久久综合九色综合绿巨人| 日韩欧美一区二区免费| 国产成人综合自拍| 亚洲欧美激情一区二区| 91精品午夜视频| 国产aⅴ综合色| 一区二区成人在线观看| 日韩欧美中文字幕制服| 成人免费看黄yyy456| 天天综合色天天综合| 久久嫩草精品久久久精品| 91小视频免费观看| 久久国产精品72免费观看| 中文字幕成人在线观看| 欧美日韩成人综合在线一区二区| 久久国产尿小便嘘嘘| 国产精品久久久久久久久图文区 | 欧美伊人久久久久久久久影院| 午夜国产精品一区| 亚洲国产精品二十页| 欧美老女人在线| 成人精品国产免费网站| 日韩电影在线一区二区| 国产精品不卡在线| 欧美成人精品福利| 91成人免费电影| 国产.精品.日韩.另类.中文.在线.播放| 亚洲精品一二三四区| 久久久国产午夜精品| 欧美精品vⅰdeose4hd| 99免费精品在线观看| 久久精品国产秦先生| 亚洲精品中文在线影院| 国产亚洲精品aa| 欧美一区二区三区四区在线观看 | 欧美videos大乳护士334| 一本色道**综合亚洲精品蜜桃冫| 国产一二精品视频| 免费在线观看成人| 亚洲成a人片在线观看中文| 国产精品久99| 国产精品入口麻豆九色| 精品国产乱码久久久久久1区2区 | 国产精品人人做人人爽人人添| 91精品国产aⅴ一区二区| 色哦色哦哦色天天综合| 99这里只有久久精品视频| 韩国三级中文字幕hd久久精品| 日韩经典中文字幕一区| 亚洲图片一区二区| 亚洲一区二区四区蜜桃| 国产精品电影一区二区三区| 亚洲国产成人午夜在线一区| 久久综合九色综合97_久久久| 91精品国产高清一区二区三区蜜臀 | 日韩欧美一级精品久久| 欧美人与z0zoxxxx视频| 欧美三电影在线| 欧美日韩一区 二区 三区 久久精品| 色婷婷av一区| 日本韩国欧美国产| 色婷婷久久久久swag精品 | 在线播放中文字幕一区| 欧美性猛交xxxx乱大交退制版| 97se亚洲国产综合在线| 99视频精品全部免费在线| 成人app下载| 99国产欧美久久久精品| 97久久久精品综合88久久| 不卡区在线中文字幕| 成人伦理片在线| 色综合夜色一区| 欧美三级日本三级少妇99| 欧美精选一区二区| 日韩欧美自拍偷拍| 久久久久久久一区| 中文字幕在线播放不卡一区| 亚洲欧美色图小说| 香蕉加勒比综合久久| 看电视剧不卡顿的网站| 国内不卡的二区三区中文字幕 | 国产欧美日韩激情| 国产日产欧美一区二区三区| 国产精品久久久久久久久动漫| 亚洲视频综合在线| 亚洲午夜三级在线| 精品一区二区三区在线播放| 国产精品一区二区男女羞羞无遮挡| 国产成a人亚洲| 91麻豆国产福利在线观看| 欧美日韩国产影片| 精品国产乱码久久| 亚洲精品欧美专区| 热久久国产精品| 成人影视亚洲图片在线| 欧美影视一区在线| 欧美sm极限捆绑bd| 国产精品国产a| 日产欧产美韩系列久久99| 国产伦精品一区二区三区免费| av不卡在线播放| 7878成人国产在线观看| 国产精品免费久久| 五月天网站亚洲| 国产不卡免费视频| 欧美日韩国产一级| 久久久国产综合精品女国产盗摄| 一区二区久久久久| 国产精品综合一区二区| 91久久精品一区二区三| 精品国产免费一区二区三区四区| 亚洲欧美电影一区二区| 国产美女精品在线| 精品视频1区2区3区| 欧美国产禁国产网站cc| 日本一区二区三级电影在线观看| 日韩电影免费在线看| 日韩一级大片在线| 亚洲色图丝袜美腿| 国产乱人伦精品一区二区在线观看| 97精品国产露脸对白| 久久久亚洲国产美女国产盗摄| 亚洲图片自拍偷拍| 99riav一区二区三区| 久久人人97超碰com| 午夜伊人狠狠久久| 91小视频免费看| 国产欧美日韩激情| 美国毛片一区二区| 欧美二区三区的天堂| 亚洲精品成人精品456| 国产精品1区2区3区| 91精品国产福利在线观看| 亚洲一区电影777| 99久久国产综合精品麻豆| 国产欧美日韩卡一| 韩国av一区二区三区四区| 欧美精品xxxxbbbb| 亚洲国产精品久久一线不卡| 99久久国产免费看| 国产精品第13页| 成人激情文学综合网| 久久久久久久综合日本| 国产一区二区三区综合| 日韩三级在线观看| 天堂资源在线中文精品| 欧美天天综合网| 夜夜嗨av一区二区三区网页 | 久久精品国内一区二区三区| 欧美日韩在线播放三区四区| 亚洲欧美在线高清| 99视频在线精品| 一区二区在线观看不卡| 91影院在线免费观看| 一区二区三区加勒比av| 色哟哟一区二区三区| 亚洲人成伊人成综合网小说| 色呦呦国产精品| 国产精品资源站在线| 久久亚洲一级片| 国产成人精品影院| 欧美韩国一区二区| 成人精品视频.| 亚洲欧美在线视频| 色中色一区二区| 亚洲韩国精品一区| 7777精品久久久大香线蕉| 日本美女视频一区二区| 精品少妇一区二区三区免费观看 | 国产二区国产一区在线观看 | 亚洲精品国产精品乱码不99| 欧洲亚洲国产日韩| 天天综合网天天综合色| 欧美v日韩v国产v| 成人免费视频国产在线观看| 亚洲女人的天堂| 777午夜精品视频在线播放| 精品亚洲国内自在自线福利| 国产精品毛片久久久久久| 一本色道久久综合狠狠躁的推荐 | 精品国产髙清在线看国产毛片| 国内不卡的二区三区中文字幕 | 久久久久久久久97黄色工厂| 成+人+亚洲+综合天堂| 亚洲一区在线免费观看|