當前位置:首頁 » 編程語言 » java雞兔同籠

java雞兔同籠

發布時間: 2025-06-25 20:25:20

⑴ 用c#(不是c++、java編程~~ 急!!! 雞兔同籠問題

已經編譯過了,放心使用,希望對你有幫助:)

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleTest //這個命名空間你相應地改一改
{
class Program
{

static void Main(string[] args)
{
int h, f;
Console.WriteLine("請輸入雞和兔的總數:");
h = int.Parse(Console.ReadLine());
Console.WriteLine("請輸入雞和兔的總腳數:");
f = int.Parse(Console.ReadLine());
for (int i = 1; i <= h; i++)
{
if ((i * 2 + (h - i) * 4) == f)
Console.WriteLine("雞有{0}只,兔有{1}只", i, h - i);
}
}
}
}

熱點內容
nist資料庫怎麼用 發布:2025-06-26 01:59:11 瀏覽:55
jsp中資料庫連接 發布:2025-06-26 01:58:28 瀏覽:202
fastcgi與phpfpm 發布:2025-06-26 01:56:12 瀏覽:287
舊安卓手機照片怎麼轉移新蘋果手機 發布:2025-06-26 01:53:08 瀏覽:449
sql增刪改查語句 發布:2025-06-26 01:47:10 瀏覽:215
7寸屏編程 發布:2025-06-26 01:41:17 瀏覽:103
用電腦搭建區域網共享伺服器 發布:2025-06-26 01:40:03 瀏覽:309
雲伺服器綁定二級域名 發布:2025-06-26 01:28:05 瀏覽:744
普通安卓充電卡扣鬆了怎麼樣解決 發布:2025-06-26 01:27:56 瀏覽:333
c語言簡單的管理系統 發布:2025-06-26 01:27:13 瀏覽:667