-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.c
52 lines (42 loc) · 1.07 KB
/
main.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
#include<stdio.h>
#include<string.h>
#include"sort.h"
int main(){
int A[] = {9,4,3,2,1,8,2,4,9,6,3};
int len = sizeof(A)/sizeof(A[0]);
int B[len], C[len], D[len], E[len];
memcpy(B, A, len*sizeof(int));
memcpy(C, A, len*sizeof(int));
memcpy(D, A, len*sizeof(int));
memcpy(E, A, len*sizeof(int));
printf("%d elements\n", len);
printf("Original Array:\n");
for(int i=0; i<len; i++){
printf(" %d", B[i]);
}
printf("\n\nSelection Sort\n");
selectionSort(A, len);
for(int i=0; i<len; i++){
printf(" %d", A[i]);
}
printf("\n\nBubble Sort\n");
bubbleSort(B, len);
for(int i=0; i<len; i++){
printf(" %d", B[i]);
}
printf("\n\nInsertion Sort\n");
insertionSort(C, len);
for(int i=0; i<len; i++){
printf(" %d", C[i]);
}
printf("\n\nMerge Sort\n");
mergeSort(D, len);
for(int i=0; i<len; i++){
printf(" %d", D[i]);
}
printf("\n\nQuick Sort\n");
quickSort(E, 0, len-1);
for(int i=0; i<len; i++){
printf(" %d", E[i]);
}
}