问题: 设计一函数,求整数区间[a,b]和[c,d]的交集。(c/c++、Java、Javascript、C#、Python)
1、Python:
def calcMixed(a,b,c,d):
rtn=[] list1=range(a,b+1) for num in range(c,d+1):
if num in list1:
rtn.append(num) return rtn mixed=calcMixed(1,8,5,9)
print(mixed)
2、
问题: 设计一函数,求整数区间[a,b]和[c,d]的交集。(c/c++、Java、Javascript、C#、Python)
def calcMixed(a,b,c,d):
rtn=[] list1=range(a,b+1) for num in range(c,d+1):
if num in list1:
rtn.append(num) return rtn mixed=calcMixed(1,8,5,9)
print(mixed)