初学者求解!
从1到30这些数里,任选7个不相同的数相加,其和值为114,并显示出每组相加的数,请高手把程序全过程写出来!非常感谢!program test;
var a,b,c,d,e,f,g:integer;
begin
assign(output,'1.txt');
rewrite(output);
for a:=1 to 24 do
for b:=a+1 to 25 do
for c:=b+1 to 26 do
for d:=c+1 to 27 do
for e:=d+1 to 28 do
for f:=e+1 to 29 do
for g:=f+1 to 30 do
if a+b+c+d+e+f+g=114 then writeln(a,',',b,',',c,',',d,',',e,',',f,',',g);
close(output);
end.
(pascal的)
真不知道这程序有什么难的了。