The wife of a programmer told him: Please go to the market and if you find ten eggs, buy them, otherwise buy some sausage. The programmer returned home with ten sausages.
What went wrong... You never know how a condition sounds in a programmer's head.
What went wrong... You never know how a condition sounds in a programmer's head.
For the geek:
Because the quantity of the sausages is not well defined in the request, the following two algorithms solve the problem correctly, although the result is unexpected for the first one.
for i=1 to 10 do
if exist 10 eggs then buy egg
else buy sausage
else buy sausage
if exist 10 eggs then
for i=1 to 10 do buy egg
else buy sausage
for i=1 to 10 do buy egg
else buy sausage




Niciun comentariu:
Trimiteți un comentariu