#include <stdlib.h>
#include <stdio.h>
#define N 10000 //¶¨ÒåÖÀ¶àÉÙ´Î
int main()
{
int s1,s2,t,i;
float z[13];
for(i=0;i<13;i++)
{
z[i]=0;//×ÜÊýÇåÁã
}
for(i=0;i<N;i++)
{
s1=rand()%6+1; //É«×Ó1Ëæ»ú
s2=rand()%6+1;
t=s1+s2; //¼ÓÆðÀ´
z[t]+=1; //´ËºÅµÄÉ«×ÓÊý¼Ó1
}
for(i=2;i<13;i++) //´Ó2ËãÆð
{
printf("num %d is %-4f%%\n",i,z[i]/N);
}
}