_andrea_

Untitled

Jul 19th, 2022 (edited)
124
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. def verifica_ordinato(array):
  2.     if len(array) < 2:
  3.         return True
  4.     for i in range(1, len(array)):
  5.         if array[i] < array[i - 1]:
  6.             return False
  7.     return True
  8.  
  9.  
  10. def principale(array):
  11.     if not verifica_ordinato(array):
  12.         array.sort()
  13.  
  14.  
  15. f = open('input.txt', "r")
  16. righe = f.read().strip().split('\n')
  17. f.close()
  18. array = [int(i) for i in righe if i]
  19. principale(array)
  20. print(array)
  21.  
  22. '''
  23. Esempio di input.txt:
  24. 3
  25. 67
  26. 3
  27. 8
  28. 89
  29. 64
  30. 34
  31. 54
  32. 76
  33. 1
  34. 98
  35. 7
  36. 4
  37. '''
  38.  
Add Comment
Please, Sign In to add comment