`
chenhsong
  • 浏览: 42541 次
  • 性别: Icon_minigender_1
  • 来自: 洛阳
社区版块
存档分类
最新评论

加密算法求解

阅读更多

试编写一个程序,求出以下加密题目的解:

TOO+TOO+TOO+TOO=GOOD

/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package Test;

/**
 *
 * @author Jasper
 */
public class puzzleMath {

    public static void main(String[] args) {
        System.out.println("TOO+TOO+TOO+TOO=GOOD result:");
        int T,O,G,D,count=0;
        for(T=0;T<=9;T++)
            for(O=0;O<=9;O++)
                for(G=0;G<=9;G++)
                    for(D=0;D<=9;D++)
                    {
                        if((3*(T*100+O*10+O))==(G*1000+O*100+O*10+D))
                        {
                            System.out.println((T*100+O*10+O)+"+"+(T*100+O*10+O)+"+"+(T*100+O*10+O)+"="+(G*1000+O*100+O*10+D));
                        }
                        count++;
                    }
        System.out.println(count+" times loop");
    }

}

 

0
1
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics