
算法
文章平均质量分 79
shitdarling
懵懵懂懂~
展开
-
递归算法的学习
此之前对递归的认识:1.递归可以通过参数实现循环结构那种计数器进行替换2.简单的尾递归与迭代等价,空间资源消耗也一样3.相对于迭代常用的循环结构,递归用判断结构,并且要有出口题目:编写函数void reverse(string&s),用递归算法使字符串s倒序一开始思考进行怎么做时就觉得参数不够用,函数的形式不正确,因为没法对字符串的下标进行迭代。然后写了个辅助函原创 2015-11-17 14:22:54 · 629 阅读 · 0 评论 -
【阿库娅教你X代码】PlayFair密码——0
大家好,我是,据说是司掌水的女神,当然也是美貌与智慧并重。今天要讲的正是密码学课本上大部分弱智的古典密码中稍微有趣一点点而且还挺使用的PlayFair密码!PlayFair密码算法的主要构成:密钥、PlayFair代换表(PF表)、(约定的)填充字母、加密算法、解密算法 Playfair密码(英文:Playfair cipher 或 Playfair square)是一种替换密码,1854年由查原创 2016-07-08 01:48:29 · 2107 阅读 · 0 评论 -
【阿库娅教你X代码】PlayFair密码——1
大家好,还是我! 这里是续上篇的内容继续来教大家完成PlayFair这个密码算法!上次讲到了完成PF表的建立,那么已经可以利用它对明文进行加密了——或者是对密文进行解密。原创 2016-07-11 01:41:40 · 1227 阅读 · 0 评论 -
RC4密码算法实现
#include#includeusing namespace std;void swap(int&, int&);int main(){ int bit;//这个bit实际是二的这个次方才对,为了避免引入算2的n次方就直接用了吧 cout > bit; int* S = new int[bit]; int* T = new int[bit]; int* key = new原创 2016-07-06 00:38:50 · 738 阅读 · 0 评论 -
PlayFair密码的实现
#include #include using std::cout;using std::string;using std::cin;using std::endl; void K_O(string* , string); void pfdcp(string et, string pf[5][5] , int alp[3][26] , string nct[]){ //原创 2016-07-05 19:05:33 · 984 阅读 · 0 评论 -
二叉树理解与实践
还原二叉树二叉树常用遍历有4种:中序(inorder)、前序/先序(preorder)、后序(postorder)、层序(levelorder),通常该类型题目会让你从前三者中选两种还原成一棵树。(当然,树的各个节点number不同) 后序+中序:Pat 1020. Tree Traversals 该题关键是考虑一棵树遍历下后序与中序的关系:后序的末尾一定是根,假设是tail,那么在中原创 2016-12-07 17:49:12 · 417 阅读 · 0 评论 -
PAT 1010. Radix (25)
PAT原题在此 Given a pair of positive integers, for example, 6 and 110, can this equation 6 = 110 be true? The answer is “yes”, if 6 is a decimal number and 110 is a binary number. Now for any pair o原创 2016-12-07 22:12:52 · 295 阅读 · 0 评论 -
PAT 1091. Acute Stroke (30)
三维图的连通路径问题,优雅的遍历方式原创 2016-12-08 21:52:56 · 309 阅读 · 0 评论 -
在PAT刷题过程的一些经验
格式问题精确到xx位 c++ #include< iomanip > cout << fixed << setprecision(1) << 6.000; 按前置0的形式读取和输出数字:比如读取 0005, 和将5输出为0005 c++ #include<iomanip> int a; cin >> a; //enter 05; cou原创 2016-12-04 16:55:37 · 4311 阅读 · 0 评论