-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.c
More file actions
46 lines (38 loc) · 729 Bytes
/
main.c
File metadata and controls
46 lines (38 loc) · 729 Bytes
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
#include "list.h"
#include <time.h>
#include <stdio.h>
#include <stdlib.h>
#define N 11
static void shuffle(int* data) {
data[0] = 0;
for (int i = 1; i < N; i++) {
int j = rand() % i;
data[i] = data[j];
data[j] = i;
}
}
int main() {
int data[N];
list_t* list = NULL;
time_t t;
#ifdef SEED
t = (time_t)SEED;
#else
time(&t);
#endif
srand((unsigned)t);
printf("random seed: %d\n", (unsigned)t);
shuffle(data);
for (int i = 0; i < N; i++)
list_push(&list, data[i]);
list_print(list, NULL);
list_qsort(&list);
puts("=>");
list_print(list, NULL);
list_invert(&list);
puts("=>");
list_print(list, NULL);
list_free(&list);
list_print(list, NULL);
return 0;
}