摘要:
摘录自《数据结构与原理》 #include <iostream> #include <memory> using namespace std; int* multi(int* num1,int size1,int* num2,int size2) { int size=size1+size2; int*... 阅读全文
摘要:
本例利用栈的先进后出,后进先出的原理解决了括号()[]{}<>匹配的问题 #include <iostream> #include <stack> using namespace std; int main() { char ch; stack<char> s; ... 阅读全文
摘要:
Vigenere加密的原理: 假设有一Vigenere密钥为(2,4,8,12,7),欲对明文helloworld加密 将明文helloworld的第一个字母移动2个位置,第二个位置移动4个位置,…,第5个字母移动7个位置,然后再从密钥的头部开始循环,直到将明文hellowrold全部转换为密文 #include <iostream> #include <c... 阅读全文
摘要:
摘录自《标准C++》 函数对象其实就是一种类似于函数的类的对象。 函数对象必须重载operator()函数 #include <iostream> #include <queue> #include <ctime> using namespace std; template <typename T> class MyCo... 阅读全文
摘要:
摘录自《标准C++》 STL提供了3种容器适配器,它们分别是栈(stack),队列(queue),优先级队列(priority_queue) 栈(先进后出,后进先出) 使用栈必须包含头文件<stack>,模板参数为 template<class T,class Container=deque<t> > ... 阅读全文
摘要:
用游程编码方式实现文件的压缩具有很大的局限性,对于类似于黑白图像这样的具有连续相同的大面积颜色块的文件有很 高的效率,但是对于彩色图像或其他相邻两点的值都不同的文件来说,反而会增大数据量 #include <iostream> #include <fstream> using namesp... 阅读全文
摘要:
//逆序输出 #include <iostream> #include <stack> #include <vector> using namespace std; int reverse(int num); int reverse(stack<char,vector<char> > ... 阅读全文