鄙人一直在论坛上查找枚举的问题,可是查找到的全是没解决的帖子;求各位大虾解决了枚举问题,日后有助于新手学习
# include <stdio.h>void main()
{
enum color {red, yellow, biue, white, black};
enum color 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=n+1;
printf ("%-4d", n);
for (loop=1;loop<=3;loop++)
{
switch (loop)
{
case1: pri=i;
break;
case2: pri=j;
break;
case3: 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 ("\n total:%5d\n", n);
}