pythonExample100/JCP089.py

24 lines
632 B
Python
Raw Blame History

This file contains invisible Unicode characters!

This file contains invisible Unicode characters that may be processed differently from what appears below. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to reveal hidden characters.

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

'''
【程序89】
题目:某个公司采用公用电话传递数据,数据是四位的整数,在传递过程中是加密的,加密规则如下:
   每位数字都加上5,然后用和除以10的余数代替该数字再将第一位和第四位交换第二位和第三位交换。
1.程序分析:
2.程序源代码:
'''
from sys import stdout
if __name__ == '__main__':
a = int(raw_input('input a number:\n'))
aa = []
aa.append(a % 10)
aa.append(a % 100 / 10)
aa.append(a % 1000 / 100)
aa.append(a / 1000)
for i in range(4):
aa[i] += 5
aa[i] %= 10
for i in range(2):
aa[i],aa[3 - i] = aa[3 - i],aa[i]
for i in range(3,-1,-1):
stdout.write(aa[i])