zoukankan      html  css  js  c++  java
  • 数据结构 —— 三羊献瑞

    今日一言:
    谢谢你,成为我前进的理由。
    ——《言叶之庭》

    数据结构 —— 三羊献瑞


    C语言实现

    /*********************************************************************************
     *
     * 三羊献瑞 (暴力破解) 
     * create: 2020年5月24日 23点17分 
     * author: LOS(小鱼) 
     *
     * *******************************************************************************/
     
    #include<stdio.h>

    void main(){
        int a; //祥
        int b; //瑞
        int c; //生
        int d; //辉
        int e = 1//三,易知
        int f; //羊 
        int g; //献
        int h; //气 
        int fir,sec,res,ver;
        for ( a = 0; a<10; a++ ){
            for ( b = 0; b<10; b++ ){
                for ( c = 0; c<10; c++ ){
                    for ( d = 0; d<10; d++ ){
                        for ( f = 0; f<10; f++ ){
                            for ( g = 0; g<10; g++ ){
                                for ( h = 0; h<10; h++ ){
                                    if( a==b || a==c || a==d || a==e || a==f || a==g || a==h ) continue;
                                    if( b==c || b==d || b==e || b==f || b==g || b==h ) continue;
                                    if( c==d || c==e || c==f || c==g || c==h ) continue;
                                    if( d==e || d==f || d==g || d==h ) continue;
                                    if( e==f || e==g || e==h ) continue;
                                    if( f==g || f==h ) continue;
                                    fir = a*1000 + b*100 + c*10 + d*1;

                                    sec = e*1000 + f*100 + g*10 + b*1;

                                    res = e*10000+ f*1000+ c*100+ b*10+ h*1;

                                    if( fir + sec == res ){
                                        printf("三 --> %d ",e);
                                        printf("羊 --> %d ",f);
                                        printf("献 --> %d ",g);
                                        printf("瑞 --> %d ",b);
                                        return;
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
    }

    运行结果

    三 --> 1
    羊 --> 0
    献 --> 8
    瑞 --> 5

    --------------------------------
    Process exited after 0.2048 seconds with return value 9
    请按任意键继续. . .

  • 相关阅读:
    如何用grep命令同时显示匹配行上下的n行 (美团面试题目)
    Maven面试宝典
    Java经典设计模式 总览
    Java设计模式之工厂模式
    Java设计模式
    三次握手,四次挥手 具体发送的报文和状态都要掌握(阿里)
    运动与饮食结合
    健身计划
    Java中的多线程=你只要看这一篇就够了
    js禁止复制粘贴
  • 原文地址:https://www.cnblogs.com/rcklos/p/12953737.html
Copyright © 2011-2022 走看看