- •Var temp,code: integer;
- •Val(inp, out, code);
- •Var temp,code: integer;
- •Val(inp, out, code);
- •Var temp,code: integer;
- •Val(inp, out, code);
- •Var temp,code: integer;
- •Val(inp, out, code);
- •Ver: real;
- •Var temp,code: integer;
- •Val(inp, out, code);
- •Var temp,code: integer;
- •Val(inp, out, code);
- •Ver: real;
- •Var temp,code: integer;
- •Val(inp, out, code);
Var temp,code: integer;
begin
fl:=true;
Val(inp, out, code);
if code=0 then
begin
fl:=true;
writeln;
end
else begin
head(hd);
writeln('Uncorrect! Please, input Number.');
write('Input: ');
fl:=false;
end;
end;
procedure turist;
var j,i,ok,A2B,n: integer;
ver1,ver2: real;
key: char;
begin
randomize;
repeat
head('***Turist***');
writeln('Please, input number of experiments...');
write('Input: ');
readln(n);
writeln;
ok:=0;
A2B:=0;
for i:=1 to n do
begin
j:=random(4)+1;
if j=1 then
begin
j:=random(3)+1;
if j=3 then ok:=ok+1;
end
else
if j=2 then
begin
ok:=ok+1;
A2B:=A2B+1;
end
else
if j=3 then ok:=ok+1
else
if j=4 then
begin
j:=random(4)+1;
if (j=1)or(j=2) then ok:=ok+1;
end;
end;
ver1:=ok/n;
ver2:=A2B/ok;
writeln('veroyatnost` popadaniya v B = ',ver1:5:4);
writeln;
writeln('veroyztnost` prohoda po AH2B = ',ver2:5:4);
writeln;
writeln('any key to continue, Esc to exit...');
key:=readkey;
until key=#27;
Рис.4. Результат работы программы ***Turist*** (Работа 4).
Работа 5 (a).
Текст программы:
uses crt;
procedure head(st:string);
begin
clrscr;
writeln(st);
writeln;
end;
procedure verif(inp:string;var out:integer;var fl:boolean;hd:string);
Var temp,code: integer;
begin
fl:=true;
Val(inp, out, code);
if code=0 then
begin
fl:=true;
writeln;
end
else begin
head(hd);
writeln('Uncorrect! Please, input Number.');
write('Input: ');
fl:=false;
end;
end;
procedure moneta;
const hd='***Brosaniye moneti***';
var
moneta, cntj, cnti, cntN, i, j: integer;
Ver: real;
st: string;
fl: boolean;
key: char;
begin
randomize;
repeat
head(hd);
writeln('Please, input number of experiments...');
write('Input: ');
fl:=false;
repeat
readln(st);
verif(st,cntN,fl,hd);
until fl=true;
cnti:=0;
cntj:=0;
for i:=1 to cntN do
begin
for j:=1 to 5 do
begin
moneta:=random(2);
write(moneta);
if moneta=1 then cntj:=cntj+1;
end;
write(' ');
if cntj>=4 then cnti:=cnti+1;
cntj:=0;
end;
writeln;
writeln;
write('Gerb vipal ne menee 4-ex raz v ');
textcolor(green);write(cnti);textcolor(7);
write(' seriyah broskov');
writeln;
ver:=cnti/cntN;
writeln('veroyatnost`= ',ver:5:4);
writeln;
writeln('any key to continue, Esc to exit...');
key:=readkey;
until key=#27;
end;
begin
moneta;
end.
Рис.5. Результат работы программы ***Brosaniye moneti*** (Работа 5 (a)).
Работа 5 (б).
Текст программы:
uses crt;
procedure head(st:string);
begin
clrscr;
writeln(st);
writeln;
end;
procedure verif(inp:string;var out:integer;var fl:boolean;hd:string);
Var temp,code: integer;
begin
fl:=true;