给定一个列表,然后给一个目标值,列表中两数求和等于目标值,要求输出列表两数的下界 如 list = [1,2,3,4,6,7,8] num=10
#!/usr/bin/python #coding=utf-8 list = [1,2,3,4,6,7,8] num=10 for m in range(len(list)): for n in range(m+1,len(list)): if list[m] + list[n] == num: print(m,n)
2022-09-17 13:37:24
给定一个列表,然后给一个目标值,列表中两数求和等于目标值,要求输出列表两数的下界 如 list = [1,2,3,4,6,7,8] num=10
#!/usr/bin/python #coding=utf-8 list = [1,2,3,4,6,7,8] num=10 for m in range(len(list)): for n in range(m+1,len(list)): if list[m] + list[n] == num: print(m,n)
下一篇:了解DevOps