假設(shè)雞兔共15只,40條腿

10年積累的成都做網(wǎng)站、網(wǎng)站建設(shè)經(jīng)驗,可以快速應(yīng)對客戶對網(wǎng)站的新想法和需求。提供各種問題對應(yīng)的解決方案。讓選擇我們的客戶得到更好、更有力的網(wǎng)絡(luò)服務(wù)。我雖然不認識你,你也不認識我。但先網(wǎng)站策劃后付款的網(wǎng)站建設(shè)流程,更有中方免費網(wǎng)站建設(shè)讓你可以放心的選擇與我們合作。
public class ChicketRubit {
public static void main(String[] args) {
int x; //兔的數(shù)目
int y; //雞的數(shù)目
for(x = 3; x = 10; x++){ //最凱氏少有3只兔子(因為只有15只雞,即30條退小于40),最多只有10只兔子(原因看前一句)
for( y = 0; y = 15; y++ ){ //雞的數(shù)目變化
if((x + y == 14) (4*x + 2*y == 40)){ //約束條件
System.out.println("兔 : "+x+" , 雞 : "+y); //輸出符合約束條盯簡散件的值咐滑
}
}
}
}
}
設(shè)置2個動態(tài)圖片在液芹寫個方慶巖法譽埋御
public void run() {
while (true) {
try {
Thread.sleep(30);
} catch (InterruptedException e) {
e.printStackTrace();
}
repaint();
}
import java.util.Scanner;
public class Test {
public static void main(String[] args){
while(true){
Scanner scanner = new Scanner(System.in);
System.out.println("請分別輸入頭的數(shù)量和腳的數(shù)量,用空格分開襪純:");
System.out.println("輸入其它內(nèi)容告鄭咐結(jié)束程序運行");
int heads,feet;
try{
heads = scanner.nextInt();
feet = scanner.nextInt();
}catch(Exception e){
break;
}
caculate(heads,feet);
}
}
public static void caculate(int head, int foot){
if((foot(int)1) != 0){
System.out.println("請輸叢搭入偶數(shù)只腳");
return;
}
if(foot 0){
System.out.println("腳數(shù)應(yīng)為非負整數(shù)");
return;
}
if(head 0){
System.out.println("頭數(shù)應(yīng)為非負整數(shù)");
return;
}
if(2*head foot){
System.out.println("頭的數(shù)量太多");
return;
}
if(4*head foot){
System.out.println("腳的數(shù)量太多");
return;
}
int che = (4*head-foot)/2;
int rub = (foot - 2*head)/2;
System.out.println("棚內(nèi)有" + che + "只雞和" + rub + "只兔子");
}
}
標題名稱:用java代碼顯示兔子 java怎么顯示代碼行數(shù)
URL網(wǎng)址:http://chinadenli.net/article2/dspphoc.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供定制開發(fā)、網(wǎng)站建設(shè)、外貿(mào)建站、App設(shè)計、響應(yīng)式網(wǎng)站、App開發(fā)
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時需注明來源: 創(chuàng)新互聯(lián)