- 有若干只鸡兔同在一个笼子里,从上面数,有35个头,从下面数,有94只脚。问笼中各有多少只鸡和兔?
package dashi;
import java.util.Scanner;
public class Cage {
public static void main(String[] args){
Scanner in =new Scanner(System.in);
String str = in.next();
int legs = 94;
int header = 35;
int chi = 0 ;
int rab = 0 ;
if((str = "所有动物抬起两条腿") != null){
legs = legs - header*2;
rab = legs/2;
chi = header - rab;
}
sop("chicken = " + chi + ";" + "rabbit = "+ rab);
}
public static void sop(Object obj){
System.out.println(obj);
}
}
|
|