Получение случайных чисел - (реферат)
p>write('¦=====================================T========================================¦'); end;{*****DoWork*****}
procedure dowork(work: byte);
begin
case work of
1: begin
textcolor(white);
textbackground(blue);
gotoxy(39, 2); write('T');
gotoxy(2, 3);
writeln(' Нормальный закон: ¦ Экспоненциальный закон: ');
gotoxy(1, 4);
write('¦=====================================+========================================¦'); drawhelp(5);
textcolor(white);
textbackground(blue);
gotoxy(2, 6); write(' Мат. ожидание: ');
gotoxy(2, 8); write(' Дисперсия: '); gotoxy(xcor[2], ycor[2]); write(dat[2]: 2: 1); gotoxy(41, 6); write('Коэффициент: '); gotoxy(xcor[3], ycor[3]); write(dat[3]: 2: 1); gotoxy(xcor[1], ycor[1]); write(dat[1]: 2: 1); i: =1;
repeat
action: =readkey;
case action of
#27: exitpar: =true;
#9: begin
i: =i+1;
if i begin
gotoxy(xcor[i], ycor[i]); write(dat[i]: 2: 1);
end
else
begin
i: =1;
gotoxy(xcor[1], ycor[1]); write(dat[1]: 2: 1);
end;
end;
#8: begin
gotoxy(xcor[i], ycor[i]); write(' ');
gotoxy(xcor[i], ycor[i]); read(dat[i]);
gotoxy(xcor[i], ycor[i]); write(dat[i]: 2: 1);
if i gotoxy(xcor[i], ycor[i]); write(dat[i]: 2: 1);
end;
#13: begin
if i gotoxy(xcor[i], ycor[i]); write(dat[i]: 2: 1);
end;
#62: begin
for i: =1 to 50 do
begin
x: =ln(random(65525)+1);
posle[i]: =exp(-sqr(x-dat[1])/(2*sqrt(dat[2])))/sqrt(2*pi*dat[2]); x: =exp(1/(random(825)));
if x
end;
end;
until exitpar=true;
drawwin;
end;
2: begin
action: =#1;
drawhelp(6);
textcolor(white);
textbackground(blue);
exitpar: =false;
j: =1;
for i: =1 to 19 do
begin
gotoxy(2, i+4);
if i+j-1
else write(' ', i+j-1, ': ', posle[i+j]: 2: 6, ' ¦ ', i+j+49, ': ', posle[i+50+j]: 2: 6) end;
repeat
action: =readkey;
case action of
#72: if j>1 then j: =j-1;
#80: if j #27: exitpar: =true;
end;
for i: =1 to 19 do
begin
gotoxy(2, i+4);
if i+j-1
else write(' ', i+j-1, ': ', posle[i+j]: 2: 6, ' ¦ ', i+j+49, ': ', posle[i+50+j]: 2: 6) end;
until exitpar=true;
drawwin;
end;
3: begin
for i: =1 to 10 do
begin
x: =0;
for j: =1 to 10 do
x: =x+posle[(i-1)*10+j];
mat[i]: =x/10;
mat0: =mat0+x;
end;
mat0: =mat0/100;
for i: =1 to 10 do
for j: =1 to 10 do
begin
disp[i]: =sqr(posle[(i-1)*10+j]-mat[i]);
disp0: =sqr(posle[(i-1)*10+j]-mat0);
end;
matmax: =mat[1];
dispmax: =disp[1];
for i: =1 to 10 do
begin
if disp[i]>dispmax then dispmax: =disp[i];
if mat[i]>matmax then matmax: =mat[i];
end;
initgraph(grdriver, grmode, '');
setBKcolor(black); setcolor(8);
for i: =1 to 11 do
line(5, i*30, 15, i*30-10);
for i: =1 to 20 do
line(i*25+5, 330, i*25+15, 320);
line(5, 330, 505, 330);
line(5, 330, 5, 30);
for i: =0 to 20 do line(i*25+15, 320, i*25+15, 20);
for i: =1 to 11 do line(15, i*30-10, 515, i*30-10);
setbkcolor(black);
for i: =1 to 10 do
begin
setcolor(cyan);
SetFillStyle(6, 7);
Bar3D(13, 27+30*(i-1), 13+round(mat[i]*10000), 35+30*(i-1), 2, TopOn); setcolor(green);
SetFillStyle(8, 8);
Bar3D(13, 35+30*(i-1), 13+round(disp[i]*1000000), 43+30*(i-1), 2, TopOn); end;
SetFillStyle(6, 7);
setcolor(8);
bar(10, 430, 20, 440);
outtextxy(23, 432, '- Mat. ozhidanie');
SetFillStyle(8, 8);
bar(10, 450, 20, 460);
outtextxy(23, 452, '- Dispersiya');
readkey;
closegraph;
drawwin
end;
end;
end;
{*****DrawMenu*****}
procedure drawmenu(button: byte);
const light=green; {15, 14, 13, 12, 11, 10, 9}
dark=white; {7, 6, 5, 4, 3, 2, 1}
var col: array[1...4]of byte;
exitmenu: boolean;
begin
exitmenu: =false;
textcolor(black);
drawhelp(1);
repeat
for i: =1 to 5 do col[i]: =dark;
col[button]: =light;
gotoxy(1, 1);
textbackground(col[1]); write(' Параметры ');
textbackground(col[2]); write(' Последовательности ');
textbackground(col[3]); write(' Гистограмма ');
textbackground(col[4]); write(' Выход '); textbackground(dark); write(' '); if button<>5 then action: =readkey else exitmenu: =true;
case action of
#77: begin
if button begin
col[button]: =dark;
button: =button+1;
col[button]: =light
end
else
begin
col[4]: =dark;
col[1]: =light;
button: =1;
end;
end;
#75: begin
if button>1 then
begin
col[button]: =dark;
button: =button-1;
col[button]: =light
end
else
begin
col[1]: =dark;
col[4]: =light;
button: =4;
end
end;
#27: exitmenu: =true;
#13: case button of
1: begin
dowork(1);
button: =5
end;
2: begin
dowork(2);
button: =5
end;
3: begin
dowork(3);
button: =5
end;
4: begin
exitmenu: =true;
exitprog: =true
end;
end;
end;
if button<>5 then drawhelp(button);
until exitmenu=true;
drawhelp(0); textbackground(dark); gotoxy(1, 1);
write(' Параметры Последовательности Гистограмма Выход ');
end;
{*****Главная программа*****}
begin
clrscr;
xcor[1]: =18;
xcor[2]: =18;
xcor[3]: =58;
ycor[1]: =6;
ycor[2]: =8;
ycor[3]: =6;
dat[1]: =5; dat[3]: =5; dat[2]: =4;
grmode: =detect;
grdriver: =detect;
drawwin;
repeat
drawmenu(5);
drawhelp(0);
actionprog: =readkey;
case actionprog of
#59: dowork(1);
#60: dowork(2);
#61: dowork(3);
#68: begin
drawmenu(1);
end;
#45: exitprog: =true;
end;
for i: =1 to 10 do begin mat[i]: =0; disp[i]: =0 end;
until exitprog=true;
end.