标题:编译无错误!无警告!为什么一运行就完蛋了??请高手看看
取消只看楼主
zd1505675319
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:139
专家分:178
注 册:2011-11-4
结帖率:100%
 问题点数:0 回复次数:1 
编译无错误!无警告!为什么一运行就完蛋了??请高手看看
#include<stdio.h>                    //程序的目的是 每次从5个颜色中取出3种 有多少种取法 然后输出排列情况
int main()
{    enum Color{red,yellow,blue,white,black};
    enum Cclor 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);
    return 0;
}
搜索更多相关主题的帖子: 众人 include 安全感 
2012-02-12 15:28
zd1505675319
Rank: 3Rank: 3
等 级:论坛游侠
帖 子:139
专家分:178
注 册:2011-11-4
得分:0 
谢谢各位
2012-02-13 15:31



参与讨论请移步原网站贴子:https://bbs.bccn.net/thread-360780-1-1.html




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

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