]>
Commit | Line | Data |
---|---|---|
28f540f4 RM |
1 | #include <stdlib.h> |
2 | #include <string.h> | |
3 | #include <stdio.h> | |
4 | ||
5 | int | |
76b87c03 | 6 | compare (const char *a, const char *b) |
28f540f4 RM |
7 | { |
8 | return strcmp (*(char **) a, *(char **) b); | |
9 | } | |
10 | ||
28f540f4 | 11 | int |
ebbad4cc | 12 | main (void) |
28f540f4 RM |
13 | { |
14 | char bufs[500][20]; | |
15 | char *lines[500]; | |
16 | size_t lens[500]; | |
17 | size_t i, j; | |
18 | ||
19 | srandom (1); | |
20 | ||
21 | for (i = 0; i < 500; ++i) | |
22 | { | |
23 | lens[i] = random() % 19; | |
24 | lines[i] = bufs[i]; | |
25 | for (j = 0; j < lens[i]; ++j) | |
26 | lines[i][j] = random() % 26 + 'a'; | |
27 | lines[i][j] = '\0'; | |
28 | } | |
29 | ||
30 | qsort (lines, 500, sizeof (char *), compare); | |
31 | ||
32 | for (i = 0; i < 500 && lines[i] != NULL; ++i) | |
33 | puts (lines[i]); | |
34 | ||
35 | return 0; | |
36 | } |