Two friends decide who gets the last slice of a cake
by flipping a coin five times. The first person to
win three flips wins the cake. An input of 1 means
player 1 wins a flip, and a 2 means player 2 wins
a flip. Design an algorithm to determine who takes
the cake?
Answers
Answered by
0
Answer:
Iuse Pseint
Explanation:
Algoritmo Program
opa,opb,cont,value,acuma,acumb son
Entero
cont=1
mientras cont<=5
value=azar(2)+1
imprimir "Value of coin is: "value
si value == 1
acuma-acuma+1
SiNo
acumb-acumb+1
FinSisi acumb 3
imprimir "Player 2 wins"
cont=5
FinSi
cont=cont+1
Fin Mientras
FinAlgoritmo
Algorithm ProgramFinSi
si acumb 3
imprimir "Player 2 wins"
cont=5
FinSi
cont=cont+1
Fin Mientras
FinAlgoritmo
Algorithm Program
opa, opb, cont, value, acuma, acumb are Integer
cont = 1
while cont <= 5cont = 5
endif
if acumb 3
print "Player 2 wins"
cont = 5
endif
cont = cont + 1
end while
End Algorithm
Similar questions
English,
2 months ago
Math,
2 months ago
Math,
2 months ago
India Languages,
5 months ago
India Languages,
5 months ago
Math,
11 months ago
English,
11 months ago
English,
11 months ago