Archived
1
0

Initial commit

This commit is contained in:
2025-10-24 17:19:46 +08:00
Unverified
commit acc0c9e220
155 changed files with 77369 additions and 0 deletions

View File

@@ -0,0 +1,46 @@
namespace C_Sharp_3_3
{
public class Program
{
static void Main(string[] args)
{
int c, r;
Console.Write("请输入总只数");
int h = int.Parse(Console.ReadLine());
int f = 1;
while (f % 2 != 0)
{
Console.Write("请输入总脚数(必须是偶数)");
f = int.Parse(Console.ReadLine());
}
// 循环
bool solution = false;
for (c = 0; c <= h; c++)
{
r = h - c;
if (2 * c + 4 * r == f)
{
Console.WriteLine("方法一:鸡有{0}只,兔有{1}只", c, r);
solution = true;
}
}
if (!solution)
{
Console.WriteLine("方法一无解");
}
// 解方程
r = f / 2 - h;
c = h - r;
solution = false;
if (c >= 0 && r >= 0)
{
Console.WriteLine("方法二:鸡有{0}只,兔有{1}只", c, r);
solution = true;
}
if (!solution)
{
Console.WriteLine("方法二无解");
}
}
}
}