-
Notifications
You must be signed in to change notification settings - Fork 1
/
maman_13.c
44 lines (33 loc) · 1.3 KB
/
maman_13.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
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include "analyzation.h"
int main(int argc, char *argv[]) {
// Getting the parameters to the program from the terminal:
// First is the array length, and second is the best/worst percentage to average.
if (argc <= 2) {
printf("Expected n and a!\n");
return 1; // Exit with error when not provided with enough arguments.
}
const int ARR_LENGTH = atoi(argv[1]);
const float PERCENTAGE_TO_AVERAGE = (float)atoi(argv[2]) / 100.f;
// Analyze for quicksort without good_pivot
printf("Running ordinary quicksort:\n");
const quicksort_analyzation ordinary =
analyze_quicksort(ARR_LENGTH, PERCENTAGE_TO_AVERAGE, false);
// Analyze for quicksort with good_pivot
printf("\nRunning quicksort with good pivot finder:\n");
const quicksort_analyzation with_good_pivot =
analyze_quicksort(ARR_LENGTH, PERCENTAGE_TO_AVERAGE, true);
printf("\n\n-----------------------\n\n");
// Print parameters from the user.
printf("N = %d, A = %.2f\n\n", ARR_LENGTH, PERCENTAGE_TO_AVERAGE);
// Print analyzations:
printf("Ordinary:\n");
print_analyzation(ordinary);
printf("\n");
printf("With Good Pivot:\n");
print_analyzation(with_good_pivot);
printf("\n");
return 0;
}