#include<stdio.h>
int main()
{
enum Color{red,yellow,blue,white,black}; //声明枚举类型enum Color
enum Color i,j,k,pri; //定义枚举变量i,j,k,pri
int n,loop;
n=0;
for(i=red;i<=black;i++)
for(j=red;j<=black;j++)
if(i!=j)
{
for(k=red;k<=black;k++)
if((k!=i)&&(k!=j))
{
n++; //符合条件加1
printf("%-4d",n); //输出第几个符合条件的组合
for(loop=1;loop<=3;loop++) //使把i,j,k的值赋值给pri,也就是把枚举类型中的颜色赋值给pri
{
switch(loop)
{
case 1: pri=i;break;
case 2: pri=j;break;
case 3: pri=k;break;
default: break;
}
switch(pri) //输出各种颜色
{
case red:printf("%-10s","red");break;
case yellow:printf("%-10s","yellow");break;
case blue:printf("%-10s","blue");break;
case white:printf("%-10s","white");break;
case black:printf("%-10s","black");break;
default:break;
}
}
printf("\n");
}
}
printf("总计:%d\n",n); //输出总有多少种组合
return 0;
}