pascal题目用一张一元票换1分,2分和5分的硬币,每种至少一枚, 问有哪几种换法。 求详细解法

2024-12-31 08:06:12
推荐回答(2个)
回答1:

用循环
var
a,b,c,d:real;
begin
a:=1;
for b:=1 to 100 do
for c:=1 to 50 do
for d:=1 to 20 do
if ((0.01*b+0.02*c+0.05*d)=1) then
writeln(b,'',c,'',d);
readln;
end.

回答2:

var
a,b,c,m:integer;
begin
for a:=1 to 100 do
for b:=1 to 50 do
for c:=1 to 20 do
if (a+2*b+5*c=100) then m:=m+1;
write(m)
end.