broadbringer

1ая задача втрой лабы

Feb 24th, 2018
85
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.62 KB | None | 0 0
  1. with open('input.txt', 'r') as InputFile:
  2.     R = InputFile.read()
  3.     R= int(R)
  4. First =  (R//1000)%10
  5. Second = (R//100)%10
  6. Third =(R//10)%10
  7. Fourth = R%10
  8. i=0
  9. while (i<5):
  10.     if(First>Second and Second>0):
  11.         a=First
  12.         First=Second
  13.         Second= a
  14.     elif (Second>=Third ):
  15.         a=Second
  16.         Second= Third
  17.         Third= a
  18.     elif(Third>=Fourth):
  19.         a= Third
  20.         Third = Fourth
  21.         Fourth = a
  22.     i+=1
  23. First= str(First);Second= str(Second);Third= str(Third);Fourth= str(Fourth);
  24. with open('output.txt', 'w') as OutputFile:
  25.     OutputFile.write(First+Second+Third+Fourth)
Advertisement
Add Comment
Please, Sign In to add comment