Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <stdlib.h>
- #include <time.h>
- #define MAX 1500
- #include "SORTW.H"
- void main(void)
- {
- static float a[MAX];
- int si, fi, N_CMP, N_MOVE;
- long t;
- void (*Fill[])(float* mas, int n) =
- {
- FillDecr, FillIncr, FillRand /*, FillEqual, FillMostly*/
- };
- void (*Sort[])(float* mas, int n, int* n_cmp, int* n_move) =
- {
- QuickSort,/* MergeSort,*/ SelectionSort, InsertionSort, BSort1,/* BSort2,*/ BSort3/*, HeapSort*/
- };
- char* SortNames[] =
- {
- "QuickSort", /*"MergeSort",*/ "SelectionSort", "InsertionSort", " BSort1",/* " BSort2",*/ " BSort3"/*, "HeapSort"*/
- };
- for (si = 0; si < sizeof(Sort) / sizeof(Sort[0]); si++)
- {
- printf("%13s: ", SortNames[si]);
- for (fi = 0; fi < sizeof(Fill) / sizeof(Fill[0]); fi++)
- {
- N_CMP = 0;
- N_MOVE = 0;
- t = clock();
- Fill[fi](a, MAX);
- Sort[si](a, MAX, &N_CMP, &N_MOVE);
- t = clock() - t;
- if (CheckSort(a, MAX))
- {
- printf("%7.2f ", t / (double)CLOCKS_PER_SEC);
- printf("%10i ", N_MOVE);
- printf("%10i ", N_CMP);
- }
- else
- printf(" no ");
- }
- printf("\n");
- }
- printf("\n");
- printf("Sortproject");
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement