Hi.
============================ nmergsrt.hpp ==================================
// ascending & descending naturalmergesort
// Copyright (C) 1998, Dominic Battre
// All rights reserved.
// You can copy and use this code freely - all you have to do is to keep my
// name in it.
#if !defined(NMERGSRT_H)
#define NMERGSRT_H
template void ascending(T array[], int l, int r) {
int left,mid,right; // Runs (left to mid, mid+1 to right)
T array2[maxSize];
do
{
right=l-1;
while (rightleft; i--) array2[i-1] = array[i-1];
for (j = mid; jleft; i--) array2[i-1] = array[i-1];
for (j = mid; j array2[j])?array2[i++]:array2[j--];
}
else
right=mid;
}
} while (left!=l);
}
#endif
Domi
Ausgezeichnet mit dem Funstar:
http://home.t-online.de/home/D_Battre
--- FIPS/32 v0.99b W95/NT [M]
---------------
* Origin: Die Bibel auf den Index --> Gewalt! (2:2457/235.12)
|