主题:求助,五色问题。
问题:
求从红黄蓝百黑五种颜色的球中,取三种颜色的球的可能取法。
我给出了如下解法:
program Fse;
type
color=(red,yellow,blue,white,black);
var
x,y,z,pri:color;
loop,total:integer;
begin
total:=0;
for x:=red to black do
for y:=red to black do
if(x<>y)then
for z:=red to black do
if (z<>x)and(z<>y)then
begin
total:=total+1;
write(total:5);
for loop:=1 to 3 do
begin
case loop of
1:pri:=x;
2:pri:=y;
3:pri:=z;
end;
case pri of
red:write('red');
yellow:write('yellow');
blue:write('blue');
white:write('white');
black:write('black');
end
end;
writeln
end;
writeln('total number:',total);
readln
end.
求高手找出毛病,并改正。加30分~
求从红黄蓝百黑五种颜色的球中,取三种颜色的球的可能取法。
我给出了如下解法:
program Fse;
type
color=(red,yellow,blue,white,black);
var
x,y,z,pri:color;
loop,total:integer;
begin
total:=0;
for x:=red to black do
for y:=red to black do
if(x<>y)then
for z:=red to black do
if (z<>x)and(z<>y)then
begin
total:=total+1;
write(total:5);
for loop:=1 to 3 do
begin
case loop of
1:pri:=x;
2:pri:=y;
3:pri:=z;
end;
case pri of
red:write('red');
yellow:write('yellow');
blue:write('blue');
white:write('white');
black:write('black');
end
end;
writeln
end;
writeln('total number:',total);
readln
end.
求高手找出毛病,并改正。加30分~