回 帖 发 新 帖 刷新版面

主题:如何用数组编这道题

program p5_2;
   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:=red to blue do
          if (m1<>m2) then
            for m3:=red 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;
            readln;
       end;
   write('total:',s);
end.

回复列表 (共1个回复)

沙发

把red等用数字表示不就行了
[em7]

我来回复

您尚未登录,请登录后再回复。点此登录或注册