Имеется четыре коробки спичек и в каждой из них по 15 спичек. Номер коробки, из которой...

0 голосов
103 просмотров

Имеется четыре коробки спичек и в каждой из них по 15 спичек. Номер коробки, из которой берется очередная спичка, выбирается случайно. Сколько спичек будет сожжено, прежде чем одна из коробок опустеет?
Составить программу на паскале


Информатика (19 баллов) | 103 просмотров
Дан 1 ответ
0 голосов
Правильный ответ

Program Fire;uses crt;var a,b,c,d,e,i,kol: integer;
beginkol:=0;a:=15;b:=15;c:=15;d:=15;randomize;for i:=1 to 60 do    begin    e:=Abs(random(5)-1);   if e=1 then a:=a-1;   if e=2 then b:=b-1;    if e=3 then c:=c-1;   if e=4 then d:=d-1;   if (a=0) or (b=0) or (c=0) or (d=0) then break;   kol:=kol+1;   end;writeln ('Kolichestvo sgorevshih spichek= ',kol);end.


(1.1k баллов)
0

program Fire;
uses crt;
var a,b,c,d,e,i,kol: integer;

begin
kol:=0;
a:=15;
b:=15;
c:=15;
d:=15;
randomize;
for i:=1 to 60 do
begin
e:=Abs(random(5)-1);
if e=1 then a:=a-1;
if e=2 then b:=b-1;
if e=3 then c:=c-1;
if e=4 then d:=d-1;
if (a=0) or (b=0) or (c=0) or (d=0) then break;
kol:=kol+1;
end;
writeln ('Kolichestvo sgorevshih spichek= ',kol);
end.