이 소스를 통해서 동일한 값이 나오게 소스를 재구성좀 부탁드려요^^
이거이름임
2023.04.01
#include stdio.h
#include time.h
#include stdlib.h
#include math.h#define N 10 //n=10
#define P 0.5 //p=0.5
#define M 100000double factorial(int n);int main()
{
int i, j, temp[M], check[21], n[21];
double p[21], q[21];
double e, s;
srand(time(NULL));
for(i=0; iM; i++) temp[i]=0;
for(i=0; i21; i++){
p[i]=0.0;
q[i]=0.0;
n[i]=0;
check[i]=0;
}
for(i=0; iM; i++){
for(j=0; j21; j++){
check[j]=rand()%2;
temp[i]+=check[j];
}
}
for(j=0;j21;j++) check[j] = j;
for(i=0;iM;i++){
for(j=0;j21;j++){
if(temp[i]==check[j]) n[j]++;
}
}
for(j=0;j21;j++){
printf(q[%d] = %.21lf\n, j ,(double)n[j]/M);
}