/*program for autocorrelation */
#include<stdio.h>
#include<conio.h>
#include<math.h>
int main()
{
int i,m,a,c,x[30]={27},count=0,M,j,k,n;
double r[30],z,R[30],sum=0.0,R0,z0,R1;
double sq,zA=1.96;
clrscr();
printf("Enter the values of a,c,m:\n");
scanf("%d%d%d\n",&a,&c,&m);
for(i=1;i<=30;i++)
{
x[i]=(a*x[i-1]+c)%m;
r[i]=(float)x[i]/m;
count++;
printf("\tRand No.::%f\n",r[i]);
}
scanf("%d%d%d",&j,&n,&M);
if((j+(M+1)*n)<= r)
{
for(k=0;k<=M;k++)
{
R[k]=r[i+(k*m)]* r[i+(k+1)*m];
sum=sum+R[k];
}
R1=sum/(M+1)-0.25;
sq=sqrt((13*M)+7);
R0=sq/(12*(M+1));
z0=R1/R0;
printf("%f",z0);
}
if(z0>=-zA && z0<=zA)
printf("\n ACCEPTED");
else
printf("\n REJECTED");
getch();
return 0;
}
Comments