/*口袋中有红、黄、蓝三种颜色的小球,
如果每次从口袋中取出2种不同颜色的
小球,打印出每种组合*/
#include<iostream>
using namespace std;
enum color {red,yellow,blue};//定义枚举类型
int main()
{
int i,j,temp;
for(i=red;i<blue;i++)//控制取出第一个小球
{
for(j=i+1;j<=blue;j++)//控制取出的第二个小球
{
for(int t=0;t<2;t++)
{
switch(t)
{
case 0:temp=i;break;
case 1:temp=j;break;
}
switch((enum color)temp)//将整型temp强制类型转换为枚举类型
{
case red:cout<<"red";break;
case yellow:cout<<"yellow";break;
case blue:cout<<"blue";break;
}
cout<<"\t";
}
cout<<"\n";
}
}
return 0;
}