我有如下三个等式:
- x + y + z = 100;
- x + y - z = 50;
- x - y - z = 10;
如何使用 Java 找到 x、y 和 z 的值?
String equation1="x+y+z=100;";
String equation2="x+y-z=50;";
String equation3="x-y-z=10;";
int[] SolveEquations(equation1,equation2,equation3) {
// to do
// how to do?
}
你们有什么可能的解决方案或其他通用框架吗?
最佳答案
您可以使用行列式来计算 x y 和 z 的值。 逻辑可以在这里找到 http://www.intmath.com/Matrices-determinants/1_Determinants.php
然后您需要使用 3 维数组在 java 中实现它。
关于java - 如何用java解方程?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/1431885/