| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 463 人关注过本帖
标题:谁能编关于枚举的例子,我网上的我看不懂
只看楼主 加入收藏
vs303791832
Rank: 2
来 自:地球
等 级:论坛游民
帖 子:87
专家分:12
注 册:2010-6-23
结帖率:76.92%
收藏
 问题点数:0 回复次数:1 
谁能编关于枚举的例子,我网上的我看不懂
求教
搜索更多相关主题的帖子: 例子 枚举 
2010-07-23 19:25
tongyuedidi
Rank: 2
等 级:论坛游民
帖 子:35
专家分:33
注 册:2013-2-20
收藏
得分:0 
# 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);
}
2013-03-26 21:26
快速回复:谁能编关于枚举的例子,我网上的我看不懂
数据加载中...
 
   



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

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