1、一个密码谜题是一种需要解谜者解码消息的谜题类型。代码被称为替换密码,其原理是在整个消息中用一个字母替换另一个字母。现在给出一个密码谜题(以字符串列表形式表示,所有字母为小写),要求编写一系列函数来辅助解决该密码谜题,具体函数及功能如下:初始化哈希表、进行替换、撤销替换、清除哈希表、解密字符串、显示密码谜题行和解密后的文本。
- 初始化全局变量
*ENCIPHER_TABLE*和*DECIPHER_TABLE*:
lisp (setf *encipher_table* (make-hash-table)) (setf *decipher_table* (make-hash-table))
- 编写函数
MAKE_SUBSTITUTION:
lisp (defun make-substitution (code clear) (setf (gethash clear *encipher_table*) code) (setf (gethash code *decipher_table*) clear))
- 编写函数
UNDO_SUBSTITUTION:
lisp (defun undo-substitution (code clear) (setf (gethash clear *encipher_table*) nil) (setf (gethash code *decipher_table*) nil))
- 编写函数
CLEAR:
lisp (defun clear () (clrhash *encipher_table*) (clrhash *decipher_table*

最低0.47元/天 解锁文章
1万+

被折叠的 条评论
为什么被折叠?



