百钱买百鸡

//百钱买百鸡,怎么买?

public class MaiJi
{
   public static void main(String[] args)
   {
       int x,y,z;//x公鸡,y母鸡,z小鸡
       for (x=0;x<=20;x++)
           for (y=0;y<=33;y++)
              for(z=0;z<=100;z++)
                {
                    if(x*5+y*3+z/3==100 && x+y+z==100 && z%3==0)
                    System.out.println("x="+x+"y="+y+"z="+z);
                 }
    }
}

运行效果:

posted on 2017-05-21 11:42  Iitb  阅读(88)  评论(0)    收藏  举报

导航