- #include <stdio.h>
- #include<stdlib.h>
- int main(int argc, const char * argv[]) {
- int a[6]={0};
- for (int i=0; i<100; i++) {
- //随机数生成函数arc4random_uniform(n) 0<=生成结果<n
- int num=arc4random_uniform(6)+1;
- a[num-1]++;
- }
- for (int j=0; j<6; j++) {
- printf("点数为%d---->置出了%d次\n",j+1,a[j]);
- }
-
- return 0;
- }
复制代码 |
|