用C#实现方程式
Realize equations with C#
如何使用自定义输入在 C# 中实现这样的方程式?
输入腿的数量和动物的数量。
animals: 35
legs: 94
x: Cows
y: Hens
Amount of animals
x + y = 35
y = 35 - x
Amount of legs
Hens: 2 legs
Cows: 4 legs
4x + 2y = 94
->
4x + 2y = 94
4x + 2(35 - x) = 94
4x + 70 - 2x = 94
2x = 24
x = 12
y = 35 - x = 35 - 12 = 23
-> 12 头奶牛
-> 23 只母鸡
如果你只有这两种动物,我的解决方案适用。
int animals = 35;
int legs = 94;
int x = (legs - 2*animals)/2;
int y = animals -x;
Console.WriteLine(x + " Cows and " + y + " hens");
如果你想解一次方程,那么你可以按照this link
如何使用自定义输入在 C# 中实现这样的方程式?
输入腿的数量和动物的数量。
animals: 35
legs: 94
x: Cows
y: Hens
Amount of animals
x + y = 35
y = 35 - x
Amount of legs
Hens: 2 legs
Cows: 4 legs
4x + 2y = 94
->
4x + 2y = 94
4x + 2(35 - x) = 94
4x + 70 - 2x = 94
2x = 24
x = 12
y = 35 - x = 35 - 12 = 23
-> 12 头奶牛 -> 23 只母鸡
如果你只有这两种动物,我的解决方案适用。
int animals = 35;
int legs = 94;
int x = (legs - 2*animals)/2;
int y = animals -x;
Console.WriteLine(x + " Cows and " + y + " hens");
如果你想解一次方程,那么你可以按照this link