C语言枚举问题

#include<stdio.h>
void main()
{
enum {red=0,yellow=1,blue=2,white=3,black=4} 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)
{case 1: pri=i;break;
                case 2: pri=j;break;
case 3: 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("\ntotal:%5d\n",n);
}

点解运行唔到?
我用的是Microfoft Visual C++
10-02-05  little_nancy 发布
1个回答
时间
投票
  • 0

    818259

    #include <stdio.h>

    enum
    {
    Qi=1,//企划部
    Cai,//财务部
    Ren,//人力资源部
    Shi,//市场部
    };

    main()
    {
    int n;

    printf("1-企划部,2-财务部,3-人力资源部,4-市场部\n");
    printf("请输入:");
    scanf("%d",&n);

    printf("你输入的是:");
    switch(n)
    {
    case 1:
    printf("企划部\n");
    break;
    case 2:
    printf("财务部\n");
    break;
    case 3:
    printf("人力资源部\n");
    break;
    case 4:
    printf("市场部\n");
    break;
    }
    }

    10-02-06 | 添加评论 | 打赏

    评论读取中....

精华知识
更多  
意见反馈 帮助