Advertisement
Guest User

Untitled

a guest
May 19th, 2019
116
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.52 KB | None | 0 0
  1. from math import ceil
  2.  
  3. inp = int(input('1 - from file; 2 - from keyboard: '))
  4. if inp == 1:
  5.     with open('input.txt', 'r') as fin:
  6.         a = fin.readline()
  7. else:
  8.     a = input('a = ')
  9. a = a.replace(' ', '')
  10.  
  11. out = int(input('1 - to file; 2 - to screen: '))
  12. if out == 1:
  13.     fout = open('output.txt', 'w')
  14. else:
  15.     fout = None
  16.  
  17. rows = ceil(len(a) ** 0.5)
  18. ml = rows * 2 - 1
  19. for i in range(rows):
  20.     cl = i * 2 + 1
  21.     print(' ' * ((ml - cl) // 2), a[i * i:(i + 1) ** 2], sep='')
  22. if out == 1:
  23.     fout.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement