Advertisement
Guest User

Untitled

a guest
May 19th, 2019
73
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 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.  
  10. out = int(input('1 - to file; 2 - to screen: '))
  11. if out == 1:
  12.     fout = open('output.txt', 'w')
  13. else:
  14.     fout = None
  15.  
  16. rows = ceil(len(a) ** 0.5)
  17. ml = rows * 2 - 1
  18. for i in range(rows):
  19.     cl = i * 2 + 1
  20.     print(' ' * ((ml - cl) // 2), a[i * i:(i + 1) ** 2], sep='')
  21. if out == 1:
  22.     fout.close()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement