Category : Recently Uploaded Files
Archive   : HEADZIP.EXE
Filename : SLCTSORT.CPP
// IMPLEMENTATION FILE (slctsort.cpp)
// This module exports a function to sort an integer vector
// into ascending order.
//----------------------------------------------------------------------
#include "slctsort.h"
// Algorithm: straight selection sort
void Sort( /* inout */ int vec[],
/* in */ int vSize )
//..................................................................
// PRE: Assigned(vSize) && Assigned(vec[0..vSize-1])
// POST: vec[0..vSize-1] contain same values as
// vec[0..vSize-1]
//..................................................................
{
int maxIndx; // Index of largest no. in each pass
int bottom; // "False bottom" for each pass
int i;
int temp;
for (bottom = vSize-1; bottom >= 1; bottom--) {
// INV (prior to test):
// All vec[0..bottom] are <= vec[bottom+1]
// && vec[bottom+1..vSize-1] are in ascending order
// && bottom >= 0
maxIndx = 0;
for (i = 1; i <= bottom; i++) // INV (prior to test):
// vec[maxIndx] >= all
// vec[0..i-1]
// && i <= bottom+1
if (vec[i] > vec[maxIndx])
maxIndx = i;
temp = vec[bottom];
vec[bottom] = vec[maxIndx];
vec[maxIndx] = temp;
}
}
Very nice! Thank you for this wonderful archive. I wonder why I found it only now. Long live the BBS file archives!
This is so awesome! 😀 I’d be cool if you could download an entire archive of this at once, though.
But one thing that puzzles me is the “mtswslnkmcjklsdlsbdmMICROSOFT” string. There is an article about it here. It is definitely worth a read: http://www.os2museum.com/wp/mtswslnk/