Advertisement
Nenogzar

matrix

May 22nd, 2024
548
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. matrix = []
  2. while True:
  3.     row_input = input()
  4.     if not row_input:
  5.         break
  6.     row_values = list(map(int, row_input.split(", ")))
  7.     matrix.append(row_values)
  8.  
  9. # Изчисляваме максималния брой колони
  10. max_columns = max(len(row) for row in matrix)
  11.  
  12. # Допълваме всеки ред с нули до максималния брой колони
  13. for row in matrix:
  14.     padding = max_columns - len(row)
  15.     row.extend([0] * padding)
  16.  
  17. for nest in matrix:
  18.     print(nest)
  19.  
  20.  
  21.  
  22. """
  23. input:
  24.  
  25. 1, 2, 3
  26. 4
  27. 5, 6
  28. 7, 8, 9, 10
  29. 1, 5
  30. 12, 2, 3, 5, 5
  31.  
  32. """
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement