Keksike

ИБ 3 лаба

Apr 27th, 2021
136
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.02 KB | None | 0 0
  1. def swap(list):  #функция reverse, но ручками(
  2.   return list[::-1]
  3.  
  4. def ListSwap(list):
  5.   res = []
  6.   for i in range(len(list)):
  7.     list[i] = swap(list[i])
  8.     res.append(list[i])
  9.   res = swap(res)
  10.   return res
  11.  
  12. alfa =' АБВГДЕЖЗИЙКЛМНОПРСТУФХЦЧШЩЬЫЪЭЮЯабвгдеёжзийклмнопрстуфхцчшщъыьэюяABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz.,-_!?0123456789@#$%^&*()'
  13.  
  14. print('Введите текст для шифрования: ')
  15. Text = input()
  16. SplitedText = Text.split()
  17.  
  18. print('Введите сдвиг: ')
  19.  
  20. res_shi = []
  21. res_des = []
  22.  
  23. for i in range(len(SplitedText)):
  24.   a = []
  25.   for j in SplitedText[i]:
  26.     a.append(alfa[(alfa.find(j))+(1 % (len(alfa)-1))])
  27.   res_shi.append(''.join(a))
  28. print(' '.join(res_shi),)
  29.  
  30. res_shi = ListSwap(res_shi)
  31.  
  32. for i in range(len(res_shi)):
  33.   a = []
  34.   for j in res_shi[i]:
  35.     a.append(alfa[(alfa.find(j))-(1 % (len(alfa)-1))])
  36.   res_des.append(''.join(a))
  37. print(' '.join(ListSwap(res_des)))
Advertisement
Add Comment
Please, Sign In to add comment