主题:组合改拍了(结果是60种)
program P5_2(input,output);
type color=(red,orange,yellow,green,blue);
var m,m1,m2,m3:color;
s,p:integer;
begin
s:=0;
for m1:=red to blue do
for m2:=succ(m1) to blue do
for m3:=succ(m2) to blue do
if (m3<>m1) and (m3<>m2) then
begin
s:=s+1;
write(s,':');
for p:=1 to 3 do
begin
case p of 1:m:=m1;
2:m:=m2;3:m:=m3;
end;
case m of
red:write('red':8);
orange:write('orange':8);
yellow:write('yellow':8);
green:write('green':8);
blue:write('blue':8);
end;
end;
writeln;
end;
writeln('total:',s);
readln;
end.
现在运行是10种,改成排列应该是60种!谢谢大家!
type color=(red,orange,yellow,green,blue);
var m,m1,m2,m3:color;
s,p:integer;
begin
s:=0;
for m1:=red to blue do
for m2:=succ(m1) to blue do
for m3:=succ(m2) to blue do
if (m3<>m1) and (m3<>m2) then
begin
s:=s+1;
write(s,':');
for p:=1 to 3 do
begin
case p of 1:m:=m1;
2:m:=m2;3:m:=m3;
end;
case m of
red:write('red':8);
orange:write('orange':8);
yellow:write('yellow':8);
green:write('green':8);
blue:write('blue':8);
end;
end;
writeln;
end;
writeln('total:',s);
readln;
end.
现在运行是10种,改成排列应该是60种!谢谢大家!