黑马程序员技术交流社区

标题: 关于踩气球游戏的思路的实现过程的参考java代码 [打印本页]

作者: Huylens    时间: 2015-5-6 12:08
标题: 关于踩气球游戏的思路的实现过程的参考java代码
public class BallGame_test {
        static boolean aTrue;
        static boolean bTrue;
        static int judge(int m,int n,int p){
                if(aTrue)return 0;
                if(m==1&&n==1)
                {
                        System.out.println("**");
                        aTrue=true;
                        return 0;
                        }
                if(n==1)bTrue=true;
                while(p>1)
                {   
                        if(m%p==0)judge(m/p,n,p-1);                       
                        if(n%p==0)judge(m,n/p,p-1);                       
                        p--;
                }
                return 0;
               
        }

        public static void main(String[] args) {
                // TODO Auto-generated method stub
                int tMax,tMin;               
                tMax=343;
                tMin=49;
                aTrue=false;
                bTrue=false;
                judge(tMax,tMin,100);
                if(!aTrue&&bTrue)
                        System.out.println("结果是:"+tMin);
                else
                        System.out.println("结果是:"+tMax);
               

        }

}







欢迎光临 黑马程序员技术交流社区 (http://bbs.itheima.com/) 黑马程序员IT技术论坛 X3.2