Advertisement
Guest User

Untitled

a guest
Feb 23rd, 2017
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.44 KB | None | 0 0
  1. f1 = open('smallsort.in', 'r')
  2. n = int(f1.readline())
  3. l = list(map(int,(str(f1.read())).split()))
  4. print(l)
  5. p=n-1
  6. while p>0:
  7. for i in range(p):
  8. if (l[i]>l[i+1]):
  9. ans=l[i]
  10. l[i]=l[i+1]
  11. l[i+1]=ans
  12. p=p-1
  13.  
  14.  
  15. f2 = open('smallsort.out', 'w')
  16. t = 0
  17. for a in l:
  18. if t != len(l) - 1:
  19. f2.write(str(a) + ' ')
  20. else:
  21. f2.write(str(a))
  22. t += 1
  23. f1.close()
  24. f2.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement