亚洲欧美第一页_禁久久精品乱码_粉嫩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一区二区三区免费野_久草精品视频
777午夜精品免费视频| 国产精品三级在线观看| 国产视频在线观看一区二区三区 | 欧美自拍偷拍午夜视频| 精品国产免费人成在线观看| 怡红院av一区二区三区| 韩国毛片一区二区三区| 91福利在线导航| 国产性天天综合网| 日韩精品乱码av一区二区| 韩国av一区二区三区四区| 日本韩国欧美在线| 中文字幕av免费专区久久| 秋霞电影网一区二区| 欧美视频一二三区| 中文字幕在线一区| 国产精品亚洲第一区在线暖暖韩国 | 91亚洲永久精品| 久久久精品中文字幕麻豆发布| 日韩在线播放一区二区| 欧美中文字幕久久| 亚洲精品亚洲人成人网在线播放| 国产成a人无v码亚洲福利| 久久综合久久久久88| 日韩1区2区3区| 777a∨成人精品桃花网| 亚洲午夜免费电影| 欧美三级欧美一级| 亚洲国产精品天堂| 欧美日韩免费观看一区二区三区 | 欧美一区二区成人6969| 午夜免费久久看| 欧美在线观看一区| 亚洲第一久久影院| 欧美在线影院一区二区| 亚洲午夜久久久久久久久电影院| 色www精品视频在线观看| 亚洲精品视频免费看| 欧美在线视频不卡| 亚洲福中文字幕伊人影院| 欧美人狂配大交3d怪物一区| 日韩有码一区二区三区| 欧美一个色资源| 国模冰冰炮一区二区| 国产亚洲制服色| yourporn久久国产精品| 伊人色综合久久天天| 欧美在线一区二区| 男人的天堂久久精品| 欧美高清dvd| 九九视频精品免费| 中文字幕精品综合| 色综合色综合色综合色综合色综合| 亚洲精品视频免费看| 欧美嫩在线观看| 国内精品国产成人国产三级粉色 | 成人亚洲一区二区一| 成人欧美一区二区三区黑人麻豆 | 国产成人免费视| 自拍偷拍亚洲激情| 欧美va亚洲va香蕉在线| 成人午夜激情片| 亚洲在线观看免费| 久久综合久久鬼色| 91网上在线视频| 蜜臀av性久久久久av蜜臀妖精 | 欧洲在线/亚洲| 久久精品99久久久| 综合欧美亚洲日本| 日韩一级大片在线观看| www.亚洲免费av| 日韩专区一卡二卡| 中文字幕一区二区三区在线不卡| 在线精品视频免费播放| 精品亚洲porn| 亚洲成在线观看| 中文字幕二三区不卡| 欧美丰满高潮xxxx喷水动漫| 国产高清不卡二三区| 天天综合网 天天综合色| 欧美极品xxx| 91精品欧美久久久久久动漫| av一区二区三区四区| 美女网站一区二区| 亚洲精品免费在线观看| 久久久国产精品麻豆| 欧美日韩国产经典色站一区二区三区| 国产高清精品网站| 日韩电影在线看| 一级中文字幕一区二区| 久久久久久一级片| 3751色影院一区二区三区| 91麻豆swag| 不卡一二三区首页| 国产精品99久久久久久久女警| 日韩成人一级片| 亚洲一区在线观看网站| 亚洲欧洲精品一区二区精品久久久 | 亚洲成av人片一区二区| 中文字幕一区二区日韩精品绯色| 精品国产免费一区二区三区四区 | 久久久91精品国产一区二区三区| 欧美一级欧美三级| 欧美色男人天堂| 色婷婷激情一区二区三区| 不卡av在线网| 成人午夜在线播放| 国产mv日韩mv欧美| 国产一区二区三区| 国产精品一区二区男女羞羞无遮挡| 蜜臀久久99精品久久久久久9| 日韩专区在线视频| 日韩av二区在线播放| 日韩电影在线免费| 秋霞午夜av一区二区三区| 午夜精品成人在线视频| 亚洲同性同志一二三专区| 欧美激情在线免费观看| 久久久久国产一区二区三区四区| 精品精品国产高清一毛片一天堂| 日韩精品一区二区三区三区免费| 欧美zozozo| 久久久久久久av麻豆果冻| 国产日产亚洲精品系列| 欧美韩国日本不卡| 中文字幕日本乱码精品影院| 中文字幕永久在线不卡| 一区二区三区中文字幕精品精品| 亚洲一区在线观看免费| 日韩黄色一级片| 久久精品国产亚洲高清剧情介绍 | 欧美一级夜夜爽| 欧美精品一区视频| 中文字幕乱码日本亚洲一区二区| 国产精品久久99| 亚洲国产美国国产综合一区二区 | 亚洲欧美日韩在线播放| 亚洲www啪成人一区二区麻豆 | 亚洲国产欧美在线人成| 久久精品国产**网站演员| 国产精品18久久久久久久网站| 97aⅴ精品视频一二三区| 欧美日韩视频在线观看一区二区三区| 正在播放一区二区| 国产婷婷一区二区| 亚洲综合成人在线视频| 激情小说欧美图片| 91丝袜美腿高跟国产极品老师| 欧美日本高清视频在线观看| 久久久亚洲午夜电影| 亚洲免费资源在线播放| 免费观看一级欧美片| a在线播放不卡| 日韩一区二区三区视频在线观看| 国产欧美日韩在线| 午夜免费久久看| 成人动漫视频在线| 日韩欧美自拍偷拍| 亚洲精品乱码久久久久久 | 香蕉久久夜色精品国产使用方法| 精品一区二区三区不卡 | 国产精品欧美精品| 日本午夜一区二区| 91视频在线看| 欧美精品一区二区三区久久久 | 色综合一个色综合亚洲| 91麻豆精品国产91久久久久久久久 | 免费美女久久99| 日本二三区不卡| 国产校园另类小说区| 日韩精品电影在线| 色视频欧美一区二区三区| 国产日韩欧美电影| 蜜芽一区二区三区| 欧美性做爰猛烈叫床潮| 欧美激情综合在线| 精品亚洲aⅴ乱码一区二区三区| 欧美日韩你懂得| 亚洲色图第一区| 国产一区二区成人久久免费影院 | 久久综合色天天久久综合图片| 亚洲国产精品久久久久秋霞影院 | 欧美视频在线一区二区三区 | 久久先锋资源网| 免费人成网站在线观看欧美高清| 99久久久久久| 久久蜜臀精品av| 国产主播一区二区| 日韩一卡二卡三卡四卡| 视频一区中文字幕| 欧美另类一区二区三区| 亚洲一区欧美一区| 在线精品国精品国产尤物884a| 日韩一区在线免费观看| 99re成人在线| 亚洲欧美综合另类在线卡通| 北岛玲一区二区三区四区| 国产精品久久久久久久午夜片 | 欧美亚男人的天堂| 亚洲成人av一区|