C语言枚举问题
#include<stdio.h>intmain(){enumColor{red,black,yellow,blue,white}i,j,k,pa;intn=0,loop...
#include<stdio.h>
int main()
{
enum Color{red,black,yellow,blue,white}i,j,k,pa;
int n=0,loop;
for(i=red;i<=white;i++)
for(j=red;j<=white;j++)
if(i!=j)
{
for(k=red;k<=white;k++)
if(k!=i&&k!=j)
{
n+=1;
printf("%-3d",n);
for(loop=1;loop<=3;loop++)
{
switch(loop)
{
case 1:pa=i;break;
case 2:pa=j;break;
case 3:pa=k;break;
}
switch(pa)
{
case red:printf("%-10s","red");break;
case black:printf("%-10s","black");break;
case yellow:printf("%-1s","yellow");break;
case blue:printf("%-10s","blue");break;
case white:printf("%-10s","white");break;
}
}
printf("\n");
}
}
printf("N:%d\n",n);
return 0;
}
e:\练习\book_325.cpp(6) : error C2676: binary '++' : 'enum main::Color' does not define this operator or a conversion to a type acceptable to the predefined operator
e:\练习\book_325.cpp(7) : error C2676: binary '++' : 'enum main::Color' does not define this operator or a conversion to a type acceptable to the predefined operator
e:\练习\book_325.cpp(10) : error C2676: binary '++' : 'enum main::Color' does not define this operator or a conversion to a type acceptable to the predefined operator
执行 cl.exe 时出错.
什么原因啊?没分了,看在C语言的份上帮忙回答下吧,谢啦。 展开
int main()
{
enum Color{red,black,yellow,blue,white}i,j,k,pa;
int n=0,loop;
for(i=red;i<=white;i++)
for(j=red;j<=white;j++)
if(i!=j)
{
for(k=red;k<=white;k++)
if(k!=i&&k!=j)
{
n+=1;
printf("%-3d",n);
for(loop=1;loop<=3;loop++)
{
switch(loop)
{
case 1:pa=i;break;
case 2:pa=j;break;
case 3:pa=k;break;
}
switch(pa)
{
case red:printf("%-10s","red");break;
case black:printf("%-10s","black");break;
case yellow:printf("%-1s","yellow");break;
case blue:printf("%-10s","blue");break;
case white:printf("%-10s","white");break;
}
}
printf("\n");
}
}
printf("N:%d\n",n);
return 0;
}
e:\练习\book_325.cpp(6) : error C2676: binary '++' : 'enum main::Color' does not define this operator or a conversion to a type acceptable to the predefined operator
e:\练习\book_325.cpp(7) : error C2676: binary '++' : 'enum main::Color' does not define this operator or a conversion to a type acceptable to the predefined operator
e:\练习\book_325.cpp(10) : error C2676: binary '++' : 'enum main::Color' does not define this operator or a conversion to a type acceptable to the predefined operator
执行 cl.exe 时出错.
什么原因啊?没分了,看在C语言的份上帮忙回答下吧,谢啦。 展开
6个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询