文章详情

  • 游戏榜单
  • 软件榜单
关闭导航
热搜榜
热门下载
热门标签
php爱好者> php文档>C语言实例50:枚举类型

C语言实例50:枚举类型

时间:2010-07-02  来源:hnrainll

#include <stdio.h>
#include <stdlib.h>

int main(int argc, char *argv[])
{
    enum color {blue, red, yellow, purple, black};
    enum color i, j, k, pri;
    int n, loop;
    n = 0;

    for(i = blue; i <= black; i++)
        for(j = blue; j <= black; j++)
        if(i != j){
        for(k = blue; k <= black; k++)
            if((k != i) && (k != j)){
            n++;
            printf("%-6d", n);
            for(loop = 1; loop <= 3; loop++)
            {
                switch(loop)
                {
                    case 1: pri = i;
                    break;
                    case 2: pri = j;
                    break;
                    case 3: pri = k;
                    break;
                    default: break;
                }
                switch(pri)
                {
                    case blue: printf("%-10s", "blue");
                    break;
                    case red: printf("%-10s","red");
                    break;
                    case yellow: printf("%-10s", "yellow");
                    break;
                    case purple: printf("%-10s", "purple");
                    break;
                    case black: printf("%-10s","black");
                    break;

                    default:break;
                }
            }
            printf("\n");
        }

    }
    printf("total: %5d\n", n);
    system("pause");
    return 0;
}


相关阅读 更多 +
排行榜 更多 +
辰域智控app

辰域智控app

系统工具 下载
网医联盟app

网医联盟app

运动健身 下载
汇丰汇选App

汇丰汇选App

金融理财 下载