| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 751 人关注过本帖
标题:帮忙!一个菜鸟问题!!!!
只看楼主 加入收藏
readyforlove
Rank: 1
等 级:新手上路
帖 子:25
专家分:0
注 册:2008-3-5
收藏
 问题点数:0 回复次数:2 
帮忙!一个菜鸟问题!!!!
枚举的一道题:很简单
#include <stdio.h>
void main()
{
    enum color{red,yellow,blue,white,black};
    enum color i,j,k,pri;
    int n=0,loop;
    for(i=red;i<=black;i++)
    {
        for(j=red;j<=black;j++)
            if(i!=j)
            {
                for(k=red;k<=black;k++)
                    if(i!=k&&j!=k)
                    {
                        printf("%-4d",++n);
                        for(loop=1;loop<4;loop++)
                        {
                            switch(loop)
                            {
                            case 1:pri=i;break;
                            case 2:pri=j;break;
                            case 3:pri=k;break;
                            }
                        }
                        switch(pri)
                        {
                        case red:printf("%-8s","red");break;
                        case yellow:printf("%-8s","yellow");break;
                        case blue:printf("%-8s","blue");break;
                        case white:printf("%-8s","white");break;
                        case black:printf("%-8s","black");break;
                        }
                        putchar('\n');
                    }
            }
    }
}
错误是:
--------------------Configuration: Cpp1 - Win32 Debug--------------------
Compiling...
Cpp1.cpp
g:\1\cpp1.cpp(7) : error C2676: binary '++' : 'enum main::color' does not define this operator or a conversion to a type acceptable to the predefined operator
g:\1\cpp1.cpp(9) : error C2676: binary '++' : 'enum main::color' does not define this operator or a conversion to a type acceptable to the predefined operator
g:\1\cpp1.cpp(12) : error C2676: binary '++' : 'enum main::color' does not define this operator or a conversion to a type acceptable to the predefined operator
执行 cl.exe 时出错.

Cpp1.obj - 1 error(s), 0 warning(s)
我用VC++6-0
搜索更多相关主题的帖子: include yellow black white color 
2008-04-06 21:01
sunkaidong
Rank: 4
来 自:南京师范大学
等 级:贵宾
威 望:12
帖 子:4496
专家分:141
注 册:2006-12-28
收藏
得分:0 
enum color i,j,k,pri;
换int

学习需要安静。。海盗要重新来过。。
2008-04-06 21:11
yunsuoyan
Rank: 1
等 级:新手上路
帖 子:31
专家分:0
注 册:2007-10-16
收藏
得分:0 
enum color{red,yellow,blue,white,black};
    enum color i,j,k,pri;//更改为:  int i,j,k,pri;//不知道你定义color的意思
    int n=0,loop;

[[it] 本帖最后由 yunsuoyan 于 2008-4-6 21:26 编辑 [/it]]
2008-04-06 21:24
快速回复:帮忙!一个菜鸟问题!!!!
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.022947 second(s), 8 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved