c primer plus 习题答案(5)

p352.6

 1 #include<stdio.h>
 2 #include<stdlib.h>
 3 #include<string.h>
 4 
 5 int main(void)
 6 {
 7     int i, j, count[10]={0}, seed[10];
 8     
 9     for(i=0; i<10; i++){
10         printf("please enter a seed.\n");
11         scanf("%d", &seed[i]);
12         srand(seed[i]);
13         for(j=0; j<1000; j++)
14         count[rand()%10]++;
15     }
16     i=0;
17     while(i<10)
18         printf("%d ", count[i++]);
19 
20     system("pause");
21     return 0;
22 }

 

posted @ 2015-05-24 22:19  pioneer1132203  阅读(126)  评论(0编辑  收藏  举报