100以内的5个数之和为100

100以内的5个数之和为100

Python 代码如下:
tmp=[0,0,0,0,0]
sum=j1=j2=j3=j4=0
for i0 in range(101):
    sum=i0
    j1=j2=j3=j4=0
    tmp[0]=i0
    for i1 in range(101):
        sum-=j1
        sum-=j2
        sum-=j3
        sum-=j4
        j1=j2=j3=j4=0
        sum+=i1
        j1=i1
        if(sum>100):
            break
        tmp[1]=i1
        for i2 in range(101):
            sum-=j2
            sum-=j3
            sum-=j4
            j2=j3=j4=0
            sum+=i2
            j2=i2
            if(sum>100):
                break
            tmp[2]=i2
            for i3 in range(101):
                sum-=j3
                sum-=j4
                j3=j4=0
                sum+=i3
                j3=i3
                if(sum>100):
                    break
                tmp[3]=i3
                for i4 in range(101):
                    sum-=j4
                    j4=0
                    sum+=i4
                    j4=i4
                    if(sum==100):
                        tmp[4]=i4
                        for j in tmp:
                            print(j,end=' ')
                        print('')
                        break

你可能感兴趣的:(python,numpy,开发语言)