Guest User

Untitled

a guest
Jun 24th, 2018
93
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.38 KB | None | 0 0
  1. def main():
  2. print("Ingrese Cantidad de filas ")
  3. rows = int(input())
  4. print("Ingrese Cantidad de Columnas ")
  5. columns = int(input())
  6. print("Filas: ", rows, "Columnas: ", columns)
  7. create_matrix(rows, columns)
  8. matriz = create_matrix(rows, columns)
  9. print("Printing the matrix.. ")
  10. print_matrix(matriz, rows, columns)
  11.  
  12. top = create_matrix(rows-1, columns)
  13. left = create_matrix(rows, columns-1)
  14. print("printing the top matrix ")
  15. print_matrix(top, rows-1, columns)
  16. print("printing the left matrix ")
  17. print_matrix(left, rows, columns-1)
  18.  
  19. enter_data(top, rows-1, columns)
  20. enter_data(left, rows, columns - 1)
  21.  
  22. print("Printing the top..")
  23. print_matrix(top, rows-1, columns)
  24. print("Printing the left..")
  25. print_matrix(left, rows, columns - 1)
  26.  
  27.  
  28. def create_matrix(rows, columns):
  29. matriz = [0] * rows
  30. for i in range(rows):
  31. matriz[i] = [0] * columns
  32. return matriz
  33.  
  34.  
  35. def print_matrix(matriz, rows, columns):
  36. for i in range(rows):
  37. for j in range(columns):
  38. print(matriz[i][j], " ", end='')
  39. print("")
  40.  
  41.  
  42. def enter_data(matrix, rows, columns):
  43. for i in range(rows):
  44. for j in range(columns):
  45. print("Ingrese datos de TOP", i, "-", j)
  46. matrix[i][j] = input()
  47. if matrix[i][j] == '':
  48. matrix[i][j] = 0
  49.  
  50.  
  51.  
  52. if __name__ == "__main__":
  53. main()
Add Comment
Please, Sign In to add comment