Describe
It is known that there is a head h in the cage, there is a foot F, asked how many chickens and rabbits in the cage, if not composed
Input
H (0F (0<f<2147483647)
Output
The number of chickens
The number of rabbits
Public class main { public static void main (String[] args) { int h = 0; int f = 0; Scanner Scanner = new scanner (system.in); h = Scanner.nextint (); f = scanner.nextint (); scanner.close (); int j The number of = 0; //chickens int t = Number of 0; //rabbits for (j = 1; j <= h; j++) { for (t = 1; t <= h; t++) { if (j+t==h && j*2+t*4 == f) { system.out.println (j); system.out.println (t); } } } }}
This article from "Endless life, toss more than" blog, please be sure to keep this source http://admxj.blog.51cto.com/10955090/1836826
It is known that there is a head h in the cage, there is a foot F, asked how many chickens and rabbits in the cage