# include & lttime.h & gt
# include & ltstdlib.h & gt
main(){
int N,I,j,z,a,b,c;
double randf
n = 100;
a=0,b=0,c = 0;
srand((無符號)時間(空));
for(I = 0;我& ltn;i++)
{
z = 0;
for(j = 1;j & lt=2 ;j++)
{
randf = RAND()/(double)RAND _ MAX;
if(randf & lt;0.5)z++;
}
int stdio = 1;
if(z = = 0)a++;
else if(z = = 1)b++;
else c++;
}
printf("%d,%d.%d ",a,b,c);
}
在上面壹個的基礎上,給a,B,c,B,c賦壹個初始值0,否則會有錯誤。
另外,這個程序是否連續投擲兩個硬幣100次,統計正面朝上零次、正面朝上壹次、正面朝上兩次的次數?