fork download
  1. # -*- coding: utf-8 -*-
  2. import sys
  3.  
  4. def main():
  5. s = sys.stdin.read()
  6. s = s.replace('\n', '')
  7. toks = s.split(' ')
  8.  
  9. ncols = len(toks)
  10. nrows = 0
  11. for t in toks:
  12. nrows = max(len(t), nrows)
  13.  
  14. m = []
  15. for r in range(0, nrows):
  16. m.append([])
  17. for c in range(0, ncols):
  18. m[r].append('*')
  19.  
  20. for r in range(0, nrows):
  21. for c in range(0, ncols):
  22. if c < len(toks) and r < len(toks[c]):
  23. m[r][ncols-c-1] = toks[c][r]
  24. else:
  25. m[r][ncols-c-1] = ' '
  26.  
  27. for r in m:
  28. for c in r:
  29. print(c, end='')
  30. print('')
  31.  
  32. if __name__ == '__main__':
  33. main()
  34.  
Success #stdin #stdout 0.03s 9260KB
stdin
謹賀新年 謹んで初春の お慶びを 申し上げます
stdout
申お謹謹
し慶ん賀
上びで新
げを初年
ま  春  
す  の