size : 1475
uploaded_on : Tue Aug 11 00:00:00 1998
modified_on : Wed Dec 8 14:03:08 1999
title : Selection Sort
org_filename : SELECT.PAS
author : Weasel
authoremail : weasel@holidayinfo.com
description : demonstrates selection sort
keywords :
tested : BP 7.0
submitted_by : The CKB Crew
submitted_by_email : ckb@netalive.org
uploaded_by : nobody
modified_by : nobody
owner : nobody
lang : pas
file-type : text/plain
category : pascal-alg-sortsearch
__END_OF_HEADER__
{This program is a demonstration of the
S E L E C T I O N S O R T
alhorithm.
How it works:
Find the smallest element and exchange it with the first in your list.
Then find the second smallest and exchange it with the one at position
two. Continue doing this until the whole list is sorted.
Written by Palfrader Peter (Weasel@holidayinfo.com) in 1998
for the Coder's Knowledge Base at http://www.netalive.org/ckb/
Released into Public Domain. Credits would be fine.
}
program sortdemo;
uses
crt;
const
NoElements = 20;
var
sortarray : array[0..NoElements-1] of integer;
procedure exchange(a, b : integer);
var
tmp : integer;
begin
tmp:=sortarray[a];
sortarray[a]:=sortarray[b];
sortarray[b]:=tmp;
end;
procedure sort;
var
run,
checkpos,
minpos : integer;
begin
for run:=0 to NoElements-2 do
begin
minpos:=run;
for checkpos:=run+1 to NoElements-1 do
if sortarray[checkpos]