1 #include <iostream> 2 #include <iomanip> 3 4 /* run this program using the console pauser or add your own getch, system("pause") or input loop */ 5 using namespace std; 6 int main(int argc, char** argv) { 7 enum color{red,yellow,blue,white,black}; 8 9 color pri; 10 int i,j,k,n=0,loop; 11 for(i=red;i<=black;i++) 12 for(j=red;j<=black;j++) 13 if(i!=j) 14 { 15 for(k=red;k<=black;k++) 16 if((k!=i)&&(k!=j)) 17 { 18 n=n+1; 19 cout <<setw(3)<<n; 20 for(loop=1;loop<=3;loop++) 21 { 22 switch(loop) 23 { 24 case 1:pri=color(i);break; 25 case 2:pri=color(j);break; 26 case 3:pri=color(k);break; 27 default:break; 28 } 29 switch(pri) 30 { 31 case red:cout<<setw(8)<<"red";break; 32 case yellow:cout<<setw(8)<<"yellow";break; 33 case blue:cout<<setw(8)<<"blue";break; 34 case white:cout<<setw(8)<<"white";break; 35 case black:cout<<setw(8)<<"black";break; 36 default:break; 37 } 38 } 39 cout<<endl; 40 } 41 42 } 43 cout<<"total:"<<n<<endl; 44 return 0; 45 }