- class BuyChicken
- {
- public static void main(String[] args)
- {
- for (int x=1 ;x<100/5 ;x++ )
- {
- for (int y=1; y<(100-5*x)/3;y++ )
- {
- for (int z=1; z<=(100-5*x-3*y)*3;z++ )
- {
- if((5*x+3*y+z/3)==100&&(x+y+z==100))
- System.out.println("买公鸡"+x+"只,母鸡"+y+"只,小鸡"+z+"只。");
- }
- }
- }
-
- }
- }
复制代码 |
|