关于100元换40个硬币的pascal程序分别为10块 5块 2块 1块的硬币program zlx433;varn1,n2,n5,n10:integer;beginwriteln;for n1:=1 to 37 do begin for n2:=1 to 37 do begin for n5:=1 to 37 do begin for n10:=1 to 37 do begin if (n
来源:学生作业帮助网 编辑:作业帮 时间:2024/11/26 08:49:24
关于100元换40个硬币的pascal程序分别为10块 5块 2块 1块的硬币program zlx433;varn1,n2,n5,n10:integer;beginwriteln;for n1:=1 to 37 do begin for n2:=1 to 37 do begin for n5:=1 to 37 do begin for n10:=1 to 37 do begin if (n
关于100元换40个硬币的pascal程序
分别为10块 5块 2块 1块的硬币
program zlx433;
var
n1,n2,n5,n10:integer;
begin
writeln;
for n1:=1 to 37 do
begin
for n2:=1 to 37 do
begin
for n5:=1 to 37 do
begin
for n10:=1 to 37 do
begin
if (n1+n2+n5+n10=40) and (n1*1+n2*2+n5*5+n10*10=100) then begin
write(n10,' ',n5,' ',n2,' ',n1);
readln;
end;
end;
end;
end;
end;
end.
嗯 不懂的是
输出答案的顺序为何是从2开始 而不是1
关于100元换40个硬币的pascal程序分别为10块 5块 2块 1块的硬币program zlx433;varn1,n2,n5,n10:integer;beginwriteln;for n1:=1 to 37 do begin for n2:=1 to 37 do begin for n5:=1 to 37 do begin for n10:=1 to 37 do begin if (n
看下最后一列一直在递增就知道
是你的循环体顺序的问题
如果你要按照10 5 2 1的顺序输出
仅需把 循环变量名称更改就好
n1 n2 n5 n10 --> n10 n5 n2 n1