python combination

Please in your favorite language seeking an array of integers the sum of which has 2 to the number of all integers, for example, 183 is an input group of integers {183,0,2, -184,367 result is {} (183,0 ), (- 184,367)}

l=【183,0,2,-184,367】

for i in range(len(l)):

    for j in range(i+1,len(l):

        if l[i]+l[j]==103:

print (183 and value pairs are: "% d,% d"% (l [i], l [j]))

  

Guess you like

Origin www.cnblogs.com/huaihe/p/11306495.html