Skip to content

Commit a280a65

Browse files
author
coppermilk
authored
Create ch12ex06.c
1 parent 5f253d0 commit a280a65

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

ch12/ch12ex06.c

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
#include <stdio.h>
2+
#include <stdlib.h>
3+
#include <time.h>
4+
#include <string.h>
5+
6+
#define COUNT 1000
7+
8+
int main() {
9+
int j;
10+
int count_arr[11];
11+
memset(count_arr, 0, sizeof(count_arr));
12+
13+
for (int i = 0; i < COUNT; i++) {
14+
j = 1 + rand() % 11;
15+
count_arr[j] += 1;
16+
//printf("%d ", j);
17+
18+
}
19+
20+
for (int j = 1; j < 11; j++) {
21+
printf("%d cout: %d\n", j, count_arr[j]);
22+
}
23+
return 0;
24+
}

0 commit comments

Comments
 (0)