Skip to content

Commit 08457f6

Browse files
AC
1 parent 3680713 commit 08457f6

File tree

1 file changed

+18
-0
lines changed

1 file changed

+18
-0
lines changed

Encode_2.py

+18
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
P = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ_.'
2+
T = 5
3+
while T > 0:
4+
inp = input()
5+
if inp == '0':
6+
break
7+
else:
8+
li = inp.split() # chuyển string về dạng list
9+
k = int(li[0])
10+
s1 = str(li[1])
11+
l = len(s1)
12+
for i in range(l):
13+
j = P.index(s1[i]) #tim index cua s1[i] trong P
14+
x = (j+k) % 28
15+
s1 = s1[:i]+P[x]+s1[i+1:] # thay đổi giá trị tại vị trí thứ i
16+
s1 = s1[::-1] # đảo ngược chuỗi số.
17+
print(s1)
18+

0 commit comments

Comments
 (0)