代码示例
#!/usr/bin/env python3
# -*- coding: UTF-8 -*-
# ---------------------------
def get_intercal():
nums = [1,3,9,8,5,2]
#nums = [1]
nums_cnt = len(nums)
file_satisfy =[nums[0]]
if nums_cnt >= 1:
tmp = 0
for i in range(0, nums_cnt-1):
if i >= tmp:
for j in range(i+1, nums_cnt):
flag = 1 if abs(nums[i]-nums[j])>5 else 0
tmp = j
if flag:
file_satisfy.append(nums[j])
break
else:
sys.exit("没有符合要求的,退出")
print(file_satisfy)
return file_satisfy