1. <ul id="0c1fb"></ul>

      <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
      <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区

      RELATEED CONSULTING
      相關(guān)咨詢
      選擇下列產(chǎn)品馬上在線溝通
      服務(wù)時間:8:30-17:00
      你可能遇到了下面的問題
      關(guān)閉右側(cè)工具欄

      新聞中心

      這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
      雞兔同籠java源代碼 雞兔同籠java源代碼解析

      用“java”如何實現(xiàn)雞兔同籠的問題?

      用“java”實現(xiàn)雞兔同籠問題如下:

      公司主營業(yè)務(wù):成都做網(wǎng)站、成都網(wǎng)站制作、移動網(wǎng)站開發(fā)等業(yè)務(wù)。幫助企業(yè)客戶真正實現(xiàn)互聯(lián)網(wǎng)宣傳,提高企業(yè)的競爭能力。成都創(chuàng)新互聯(lián)是一支青春激揚、勤奮敬業(yè)、活力青春激揚、勤奮敬業(yè)、活力澎湃、和諧高效的團隊。公司秉承以“開放、自由、嚴謹、自律”為核心的企業(yè)文化,感謝他們對我們的高要求,感謝他們從不同領(lǐng)域給我們帶來的挑戰(zhàn),讓我們激情的團隊有機會用頭腦與智慧不斷的給客戶帶來驚喜。成都創(chuàng)新互聯(lián)推出浮梁免費做網(wǎng)站回饋大家。

      System.out.println("---------雞兔同籠問題------");

      int head, foot;

      int ji[] = { 0 }, tu[] = { 0 };

      System.out.print("輸入頭數(shù):");

      Scanner scanner = new Scanner(System.in);

      head = scanner.nextInt();

      System.out.print("輸入腳數(shù):");

      foot = scanner.nextInt();

      JTTL(head,foot,tu,ji);

      System.out.println("雞有"+ji[0]+"個"+","+"兔有"+tu[0]+"個");

      }

      private static void JTTL(int head, int foot, int[] tu, int[] ji) {// TODO Auto-generated method stubtu[0]=foot/2-head;ji[0]=2*head-foot/2;}}

      雞兔同籠java程序頭20個,腿62

      完整代碼如下,復(fù)制到eclipse中運行

      import?java.util.Scanner;

      /**

      *?雞兔同籠java程序頭20個,腿62

      *?@author?Administrator

      *

      */

      public?class?Cube?{

      public?static?void?main(String?args[])?{

      int?head?=?0;

      int?foot?=?0;

      String?in?=?"";

      String[]?parameters;

      Scanner?input?=?new?Scanner(System.in);

      System.out.println("請輸入頭和腳的數(shù)量(用英文逗號隔開):");

      try?{

      while?(true)?{

      in?=?input.next();

      parameters?=?in.split(",");

      head?=?Integer.parseInt(parameters[0]);

      foot?=?Integer.parseInt(parameters[1]);

      if?(foot??2?||?foot?%?2?!=?0)?{

      System.out.println("請輸入正確的腳數(shù)...");

      continue;

      }?else?{

      break;

      }

      }

      }?catch?(Exception?e)?{

      //?TODO?Auto-generated?catch?block

      System.out.println("輸入有誤!程序退出。");

      System.exit(-1);

      }

      int?ji?=?0,?tuMax;

      tuMax?=?foot?/?4;?//?兔子的最大值

      for?(int?tu?=?0;?tu?=?tuMax;?tu++)?{

      ji?=?(foot?-?4?*?tu)?/?2;?//?從兔子個數(shù)為0開始測試,窮舉所有情況

      if?(ji?+?tu?==?head)?{?//?如果雞兔數(shù)量=頭數(shù),則輸出

      System.out.println("雞有"?+?ji?+?"只\t兔子有"?+?tu?+?"只");

      }

      }

      }

      }

      運行結(jié)果如圖:

      用java怎么實現(xiàn)雞兔同籠的問題

      以“今有雉兔同籠,上有三十五頭,下有九十四足,問雉兔各幾何?”為例

      public?class?test?{

      public?static?void?main(String[]?args)?{

      int?x,y;??//x:雞??y:兔

      for(x=0;x=35;x++)?{???//遍歷雞的只數(shù)

      y=35-x;????????//兔的只數(shù)等于35?-?雞

      if(2*x+4*y==94)???//如果雞和兔的腳總數(shù)是94????????????

      System.out.println("雞"+x+"只,兔"+y+"只");

      }

      }

      }


      當(dāng)前名稱:雞兔同籠java源代碼 雞兔同籠java源代碼解析
      文章URL:http://www.ef60e0e.cn/article/dodpies.html
      99热在线精品一区二区三区_国产伦精品一区二区三区女破破_亚洲一区二区三区无码_精品国产欧美日韩另类一区
      1. <ul id="0c1fb"></ul>

        <noscript id="0c1fb"><video id="0c1fb"></video></noscript>
        <noscript id="0c1fb"><listing id="0c1fb"><thead id="0c1fb"></thead></listing></noscript>

        大石桥市| 九寨沟县| 元氏县| 北碚区| 鹿邑县| 沂南县| 出国| 城步| 临江市| 武义县| 蒙自县| 中阳县| 博乐市| 巨野县| 伊金霍洛旗| 高邮市| 山东省| 黄平县| 德阳市| 读书| 屯留县| 神池县| 温泉县| 攀枝花市| 卢氏县| 江源县| 肃南| 安福县| 松溪县| 布拖县| 额尔古纳市| 普格县| 阳江市| 钟祥市| 浦城县| 南和县| 罗甸县| 怀宁县| 曲靖市| 西吉县| 攀枝花市|