这是我在这里发布的第一篇文章。今天我开始使用Java的组合库。
这个库是:https://github.com/dpaukov/combinatoricslib3
我在Excel中有超过10k条三角形边长数据,然后将它们导入到2D整数数组中。
然后我创建了一个名为Triangle的类:
public class Triangle {
private int a;
private int b;
private int c;
public Triangle(int a, int b, int c)
{
this.a = a;
this.b = b;
this.c = c;
}
public boolean isCorrect()
{
if(this.a + this.b > this.c)
return true;
return false;
}
我的问题是我可以生成所有可能的三角形组合,但不知道如何创建三角形对象。只知道如何打印结果。
public static void main(String[] args) throws IOException {
Generator.combination(sides).simple(3).stream().forEach(System.out::println);
}
谢谢您的提前帮助。干杯!
编辑:
这是边缘的例子:
static final int[][] sides = new int[][]{
{71, 100, 1231, 832, 127},
{336, 447, 815, 658, 373},
{126, 444, 556, 221, 1322},
{1226, 662, 985, 87, 991},
{555, 512, 111, 339, 22},
};
我希望能够使用这些数据生成所有可能的三角形。