关于枚举的问题
程序代码:
#include <stdio.h> void main() { enum color {red,yellow,blue,white,black}; enum color i,j,k,y; int n=0,x; for(i=red;i<=black;i++) { for(j=red;j<=black;j++) { for(k=red;k<=black;k++) { if(i!=j&&i!=k&&j!=k) { n++; printf("%d:\t",n); for(x=1;x<=3;x++) { switch(x) { case 1:y=i;break; case 2:y=j;break; case 3:y=k;break; } switch(y) { case red:printf("%5s","red");break; case yellow:printf("%5s","yellow");break; case blue:printf("%5s","blue");break; case white:printf("%5s","white");break; case black:printf("%5s","black");break; } } } putchar('\n'); } } } printf("total:%d\n",n); }
怎么会这样!