SHARE
TWEET

Untitled

a guest Dec 2nd, 2019 101 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. n = int(input('Введите количество строк и столбцов матрицы: '))
  2. matrix = []
  3. m = (n**2)// 2
  4. for i in range(n):
  5.     matrix.append([])
  6.     for j in range(n):
  7.         matrix[i].append([])
  8.         matrix[i][j] = int(input('Введите значение элемента: '))
  9. print('Исходная матрица: ')
  10. for i in range(n):
  11.     print(matrix)
  12. def conv():
  13.     saved_matrix = []
  14.     for i in range(n):
  15.         saved_matrix.append([])
  16.         for j in range(n):
  17.             saved_matrix[i].append([])
  18.             saved_matrix[i][j]= matrix[i][j]
  19.     for i in range(n):
  20.         for j in range(n):
  21.             matrix[i][j] = matrix[j][i]
  22.         for j in range(n):
  23.             matrix[i][j] = saved_matrix[j][i]
  24.     print('Конвертированная матрица: ')
  25.     for i in range(n):
  26.         print(matrix[i])
  27.     menu()
  28. def print_element():
  29.     i = int(input('Введите строку: '))
  30.     j = int(input('Введите столбец: '))
  31.     i = i-1
  32.     j = j-1
  33.     print('Элемент:', matrix[i][j])
  34.     menu()
  35. print()
  36. def menu():
  37.     print('----------Меню----------\n 1 - Конвертация\n 2 - Вывод элемента\n 3 - Выход')
  38.     key = int(input('Введите номер пункта меню: '))
  39.     if key == 1:
  40.         conv()
  41.     elif key == 2:
  42.         print_element()
  43.     elif key == 3:
  44.         exit()
  45.     else:
  46.         menu()
  47. menu()
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
Not a member of Pastebin yet?
Sign Up, it unlocks many cool features!
 
Top