향민이형이 관련 내용을 포스팅 했기에 여기엔 내가 짯던 코드만 게시.
#include<stdio.h>
#include<stdlib.h>
#include<time.h>
#include<math.h>
#include<string.h>
int main()/*1 Dimensional Yut Nori*/
{
srand(time(NULL));
int i,j;
int k=0;
int n=0;/*Determine Do Gae Geol Yut Mo*/
int m=0;/*Steps for one trial*/
double rnd;
int max;/*Number of trial*/
printf("How many times do u want to try?\n");
scanf("%d",&max);
for(j=0; j<max; j++)
{
n=0;
m=0;
for(i=0; i<4; i++)
{
rnd=(double)(rand()/(RAND_MAX+1.0-1.0));
if(rnd<=0.6)
{
n++;
}
if(i==3&&n==0)
{
n=5;
}
if(i==3&&(n==4||n==5))
{
i= -1;
m=m+n;
n=0;
}
if(i==3)
{
m=m+n;
}
}
k=k+m;
}
printf("%lf\n",(double)k/(double)max);
return 0;
}