// Testsort.cpp: Defines the entry point of the console application. //
#include "stdafx.h" #include Printf ("% s, count =% D Time =% D", S, C, Clock () - T); for (int i = 0; i <25; i ) {IF (i% 25 == 0) Printf ("/ n"); Printf ("% D", A [i]); } Printf ("/ n"); Void shellsort (int A [], int N) {int GAP, I, J; For (GAP = N / 2; GAP> 0; GAP = GAP / 2) for (i = gap; i Void SunXysort (int B [], INT D) {INT P = 0; for (int i = 0; i // Partition do {while (a [i] // Recursion IF (LO Void Quicksort2 (Int a [], int N) {Quicksort (A, 0, N-1);} void sift (int key [], int L, int m) {INT I, J, X; i = L; J = 2 * i; x = key [i]; while (j <= m) {C ; IF (j Void Heapsortb (int key [], int N) {INT I, W; // compct = shiftcount = 0; for (i = n / 2; i> = 1; I -) {sift (key, i, n ); c ;} for (i = n; i> = 2; i -) {C ; w = key [i]; // shiftcount ; key [i] = key [1]; // shiftcount ; key [ 1] = W; // ShiftCount ; SIFT (Key, I-1, 1);} return;} voidheapsort (int key [], int N) {INT I, J; int = n; // - 1 int = L = (n >> 1) 1; int RRA; for (;;) {if (l> 1) {RRA = Key [- l-001];} else {ra = key [IR-001]; Key [IR-001] = Key [1-001]; C ; IF (--ir == 1) {key [1-001] = RRA; C ; return;}} i = L; j = l << 1; While (j <= IR) {IF (j INT_TMain (int Argc, _tchar * argv []) {Test ("Quicksort", Quicksort2, CP, 2500); TEST ("Insertsort", Insertsort, CP, 2500); TEST ("Shellsort", Shellsort, CP, 2500 TEST ("SelectSort", SelectSort, CP, 2500); TEST ("Bubblesort", Bubblesort, CP, 2500); TEST ("Sunxysort", Sunxysort, CP, 2500); Test ("Heapsort", Heapsort, CP , 2500); return 0;}