//JS pseudo TurboPascal simulator script //program gauss; {Lutz Tautenhahn (c) 1992)} var form=80; var graphdriver,graphmode; var nn; var y=[]; var z,r,fi,x; var zahl; var xi,yi,i,mx,my; var s; function run() { if (nreadln<1) { nn=0; initgraph(); mx=getmaxx; my=getmaxy; for (i=1; i<=mx; i++) putpixel (i,my,8); for (i=1; i<=my; i++) putpixel (320,i,8); for (i=1; i<=650; i++) y[i]=1; do { do { z=Math.random(); z=(1-z)*(1-z); } while(z==0); nn=nn+1; r=Math.sqrt(Math.log(1/z)); z=Math.random(); fi=2*Math.PI*z; x=r*Math.cos(fi); xi=Math.round(form*x)+320; if ((1<=xi)&&(xi<=mx)) { y[xi]=y[xi]+1; yi=my-y[xi]; putpixel(xi,yi,15); } } while(nn<68315); readln(''); return; } if (nreadln<2) { for (i=1; i<=mx; i++) putpixel (i,my,8); for (i=1; i<=my; i++) putpixel (320,i,8); settextstyle(1,'horizdir',2); settextjustify('left','top'); outtextxy(10,10,nn); settextstyle(4,'horizdir',10); settextjustify('center','top'); outtextxy(320,20,'Gauss'); for (i=1; i<=mx; i++) putpixel(i,my-y[i],15); readln(''); return; } closegraph(); exit(); }