#include <stdlib.h> ?
#include <stdio.h> ?
#include <time.h> ?
#define TIMES 1000
void bubble_sort(int arr[], int len);
int count_num(int arr[], int num);
int main (void)
{
?? ?int i;
?? ?int roll[TIMES];
?? ?srand((unsigned int)time (NULL));
?? ?for(i=0;i<TIMES;i++)
?? ??? ?roll[i] = rand()%10+1 ;
?? ?for(i=1;i<=10;i++)
?? ??? ?printf("[%d]_times=%d\n",i,count_num(roll, i));
?? ?return 0;
}
int count_num(int arr[], int num)
{
?? ?int i,count=0;//必须初始化为0?
?? ?for(i=0;i<TIMES;i++)
?? ?{
?? ??? ?if(arr[i]==num)
?? ??? ??? ?count++;
?? ?}
?? ?return count;
}
?