PROGRAM temp(input,output);
VAR
result,p:real;
r,i,n,m:longint;
a,b,c,d:boolean;
BEGIN
writeln('Please input a number of the amount of prize <2^31');
writeln('input 88 (means bye-bye) to exit');
While r<>88 do begin
readln(r);
p:=0;
FOR i:=1 TO r DO
BEGIN
m:=0;
a:=false;
b:=false;
c:=false;
d:=false;
REPEAT
n:=RANDOM(4);
CASE n OF
0:a:=true;
1:b:=true;
2:c:=true;
3:d:=true;
END;{CASE}
m:=m+1;
UNTIL a AND b AND c AND d;
p:=p+m;
END;
result:=p/r;
writeln('The average of ice-cream to buy is:',result);
end;
end.
VAR
result,p:real;
r,i,n,m:longint;
a,b,c,d:boolean;
BEGIN
writeln('Please input a number of the amount of prize <2^31');
writeln('input 88 (means bye-bye) to exit');
While r<>88 do begin
readln(r);
p:=0;
FOR i:=1 TO r DO
BEGIN
m:=0;
a:=false;
b:=false;
c:=false;
d:=false;
REPEAT
n:=RANDOM(4);
CASE n OF
0:a:=true;
1:b:=true;
2:c:=true;
3:d:=true;
END;{CASE}
m:=m+1;
UNTIL a AND b AND c AND d;
p:=p+m;
END;
result:=p/r;
writeln('The average of ice-cream to buy is:',result);
end;
end.