A股上市公司传智教育(股票代码 003032)旗下技术交流社区北京昌平校区

 找回密码
 加入黑马

QQ登录

只需一步,快速开始

© 杜光 高级黑马   /  2013-6-8 19:26  /  913 人查看  /  1 人回复  /   0 人收藏 转载请遵从CC协议 禁止商业使用本文

  1. package Two;
  2. import java.util.Scanner;
  3.   public class Gao
  4.         {
  5.           public static void main(String args[]) {
  6.           System.out.println("---------鸡兔同笼问题------");
  7.           int head, foot;
  8.           int ji[] = { 0 }, tu[] = { 0 };
  9.           System.out.print("输入头数:");
  10.           Scanner scanner = new Scanner(System.in);
  11.           head = scanner.nextInt();
  12.           System.out.print("输入脚数:");
  13.           foot = scanner.nextInt();
  14.           JTTL(head,foot,tu,ji);
  15.           System.out.println("鸡有"+ji[0]+"个"+","+"兔有"+tu[0]+"个");
  16.   }
  17.   
  18.         private static void JTTL(int head, int foot, int[] tu, int[] ji)
  19.         {
  20.           // TODO Auto-generated method stub
  21.           tu[0]=foot/2-head;
  22.           ji[0]=2*head-foot/2;
  23.   }
  24. }
复制代码

1 个回复

正序浏览
值得学习ing!
回复 使用道具 举报
您需要登录后才可以回帖 登录 | 加入黑马