Advertisement
mohammad-hadi-babalu

رفع اشکال 3

Jan 10th, 2016
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.43 KB | None | 0 0
  1. def swap(A,i,j):
  2.     a=A[i]
  3.     A[i]=A[j]
  4.     A[j]=a
  5. def bubblesort(A):
  6.     n=len(A)-1
  7.     for i in range(n-1):
  8.         for j in range(n-i):
  9.             if A[j]>A[j+1]:
  10.                 swap(A,j,j+1)
  11.    
  12. def tr(a):
  13.     b=0
  14.     while a!=0:
  15.         a=a//10
  16.         b=b+1
  17.     return b
  18. a=int(input())
  19. b=tr(a)
  20. A=b*[0]
  21. for i in range(b):
  22.     A[i]=a//10**i%10
  23. bubblesort(A)
  24. c=0
  25. for i in range(b):
  26.     c=c+A[i]*10**i
  27. print(c)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement