三角顶点 - Lua计算?

时间:2014-10-01 20:13:27

标签: lua

我目前决定在Lua中完成一个问题,并且不知道从哪里开始。我正在考虑从模数运算符开始。我正在寻找经验丰富的Lua程序员关于如何编程的建议,主要是我如何计算问题的理论数学方面。

Source of the question... (http://www.eecs.qmul.ac.uk/~pbo/ACM/archive/00209.html)

任何正确回答的人都会感恩。 感谢信。

1 个答案:

答案 0 :(得分:0)

function get_left(max)
    i = 0
    j = 1
    ls = {}

    repeat
        i = i + 1
        j = j + i - 1
        ls[i] = j
        print (ls[i], " ls")
    until j >= max

    return ls
end

a = get_left(27)

(需要将其格式化为代码-.-)

if the point1 is between a[i] and a[i+1]
if then point2 is still between a[i] and a[i+1] it is on the same line
else if point2 is between a[i + n] and a[i + n + 1]
then if point2 is at a[i + n] + (a[i] - point1) + n + 1 its in a strait line right above it
else if point2 is at a[i + n] + (a[i] - point1) + n - 1 its in a strait line left above it

if for all points n or n*(-1) is equal the distance between the points is equal.

即如果我没有出现任何逻辑错误,您可能需要检查更多以使其正常工作。

这是一个比lua更多的数学问题我建议添加一个数学标签。