1 #include "stdio.h"
2 double rnd1(double *r)
3 { int m;
4 double s,u,v,p;
5 s=65536.0; u=2053.0; v=13849.0;
6 m=(int)(*r/s); *r=*r-m*s;
7 *r=u*(*r)+v; m=(int)(*r/s);
8 *r=*r-m*s; p=*r/s;
9 return(p);
10 }
11 main()
12 { int i;
13 double r;
14 r=5.0;
15 printf("\n");
16 for (i=0; i<=9; i++)
17 printf("%10.7lf\n",rnd1(&r));
18 printf("\n");
19 getch();
20 }
1
2
3 #include "stdio.h"
4 void rnds(r,p,n)
5 double *r,p[];
6 int n;
7 { int i,m;
8 double s,u,v;
9 s=65536.0; u=2053.0; v=13849.0;
10 for (i=0; i<=n-1; i++)
11 { *r=u*(*r)+v; m=(int)(*r/s);
12 *r=*r-m*s; p[i]=*r/s;
13 }
14 return;
15 }
16 main()
17 { int i,j;
18 double p[50],r;
19 r=1.0;
20 rnds(&r,p,50);
21 printf("\n");
22 for (i=0; i<=9; i++)
23 { for (j=0; j<=4; j++)
24 printf("%10.7lf ",p[5*i+j]);
25 printf("\n");
26 }
27 printf("\n");
28 getch();
29 }
30