Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- f1 = open('smallsort.in', 'r')
- n = int(f1.readline())
- l = list(map(int,(str(f1.read())).split()))
- print(l)
- p=n-1
- while p>0:
- for i in range(p):
- if (l[i]>l[i+1]):
- ans=l[i]
- l[i]=l[i+1]
- l[i+1]=ans
- p=p-1
- f2 = open('smallsort.out', 'w')
- t = 0
- for a in l:
- if t != len(l) - 1:
- f2.write(str(a) + ' ')
- else:
- f2.write(str(a))
- t += 1
- f1.close()
- f2.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement