60 lines
1.1 KiB
C
60 lines
1.1 KiB
C
#define _CRT_SECURE_NO_WARNINGS
|
|
#include <Windows.h>
|
|
#include <string.h>
|
|
#include <time.h>
|
|
#include <stdio.h>
|
|
#include "SortString.h"
|
|
|
|
char filename[] = "D:\\university\\ÎÀÈÏ\\lab\\additional_materials\\L25\\Texts\\dict4b.txt";
|
|
|
|
void main() {
|
|
SetConsoleCP(1251);
|
|
SetConsoleOutputCP(1251);
|
|
|
|
long t0 = clock();
|
|
LoadWords(filename);
|
|
printf("array lenth = %d, file = %s\n", n, filename);
|
|
|
|
int t1 = clock();
|
|
printf("Run time of array loading = %.7f sec\n",
|
|
(t1 - t0) / (float)CLOCKS_PER_SEC);
|
|
|
|
char now_str[80];
|
|
|
|
for (int i = 0; i < 4; i++) {
|
|
long tt1 = clock();
|
|
|
|
fillArrayStrings();
|
|
|
|
switch (i)
|
|
{
|
|
case 0:
|
|
QuickSortStrings();
|
|
strcpy(now_str, "quick");
|
|
break;
|
|
case 1:
|
|
SelectionSortStrings();
|
|
strcpy(now_str, "select");
|
|
break;
|
|
case 2:
|
|
InsertSortStrings();
|
|
strcpy(now_str, "insert");
|
|
break;
|
|
case 3:
|
|
BubbleSortStrings();
|
|
strcpy(now_str, "buble");
|
|
break;
|
|
}
|
|
|
|
long tt2 = clock();
|
|
printf("Run time of %s sorting = %.10f sec\n",
|
|
now_str,
|
|
(tt2 - tt1) / (float)CLOCKS_PER_SEC);
|
|
|
|
if (!isSortedStrings()) {
|
|
printf("Array is not sorted!!!\n");
|
|
return;
|
|
}
|
|
}
|
|
}
|