Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def summ(x):
- s=0
- w=x
- while w>0:
- s+=w%10
- w//=10
- return s
- Fin=open("input.txt")
- Fout=open("output.txt", "w")
- A=[]
- while True:
- s=Fin.readline()
- if not s: break
- A.append(int(s))
- N=len(A)
- for i in range(N-1):
- for j in range(N-i-1):
- if summ(A[j]) > summ(A[j+1]):
- A[j], A[j+1] = A[j+1], A[j]
- print(A)
- Fout.write(str(A))
- Fin.close()
- Fout.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement