繁体   English   中英

我如何找到给定点的最大长度并使程序在最大长度到达中间的那个点之后停止?

[英]how do i find the greatest length from a given point and make the program stop after that point with the greatest length hits the middle?

我的程序制作了 30 个随机生成的点,这些点从地图的边缘向中心移动。 我的程序运行良好,但是我如何找到这些点的最大长度,然后说“如果最大长度到达中间,则重置?

我只是不知道如何

biggestLength = 0

lengthList = []
after = 1

length = math.sqrt(dx * dx + dy * dy)

lengthList.append(length)
biggestLength = lengthList[0]
if len(lengthList) == 30:
    while x < 30:
        if lengthList[after] > biggestLength:
            lengthList[after] = biggestLength
        after += 1
        x += 1
    lastWaste = lengthList.index(biggestLength)
    print (biggestLength)
    lengthList = []

列表的最大值可以通过max获得:

biggestLength = max(lengthList)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM