随笔分类 - 算法
摘要:#include using namespace std;#include #include typedef struct { char data; int weight; int left; int right; int parents; int code;}Huf...
阅读全文
摘要:/* 归并排序实现 coder:QPZ time:2014-12-03*/#include #include #include using namespace std;class Mergesort{ private: ...
阅读全文
摘要:/* 例如,对于数列{pi}={5,3, 8, 2, 9},Huffman树的构造过程如下: 1. 找到{5, 3, 8, 2, 9}中最小的两个数,分别是2和3,从{pi}中删除它们并将和5加入,得到{5, 8, 9, 5},费用为5。 2. 找到...
阅读全文
摘要:/* 快速排序的实现 coder:QPZ time:2014-12-04*/#include #include #include using namespace std;#define N 10void Swap(int &a,int &b){ int t; t...
阅读全文
摘要:/* * 瞬间判断2的幂 * coder:QPZ * time:2014-12-01 */ #include using namespace std; int main(void) { int n; cin>>n; if(!(n&(n-1))){ ...
阅读全文
摘要:/* n!尾数有几个0 */#include using namespace std;void find0(int n); int find(int i,int n);int main(void){ int n; cin>>n; find0(n); return 0...
阅读全文
摘要:排序算法思想描述---qpz一、直接选择排序法a) 核心思想:在无序区间寻找最值与无序区间首元素交换 遍历所有元素排序1. 记录无序区间第一个元素位置2. 向后遍历所有元素寻找最值位置(寻找最大值还是最小值取决于降序还是升序)3. 遍历结束以后找到最...
阅读全文
摘要:/* * 装箱问题 * 算法:贪婪 * coder:qpz * time:2014-11-23 */#include #include using namespace std;#define MAX 20/*第一步:创建物品字典 */ typ...
阅读全文
摘要:/* N*N矩阵的旋转 不开辟新空间 programmer:qpz time:2014-11-09*/#include using namespace std;//#define MAX 3const int MAX=3;class cou{ priva...
阅读全文
摘要:/* 探索内存对齐 coder:瞿鹏志 */ #include #include using namespace std; #pragma pack (8)typedef struct node2{ int a;//4 char b;//4 }node_...
阅读全文
摘要:/* 最大公约数,最小公倍数 programmer:qpz time:2014-11-03*/#include #include #include #define MAX 10void delay(int a,int b){ int j,k; ...
阅读全文
摘要:/* Sort programmer:qpz time:2014-11-02*/#include #define MAX 10//冒泡排序法 void BubbleSort(int *data,int n);//直接插入排序法void StraightInsert...
阅读全文
摘要://循环队列//约瑟夫环#include#include#include#define Size 10using namespace std;class Joseph{private: int num[Size];//队列 int first;//第一个人 in...
阅读全文
摘要:/* vector function template programmer:qpz*/#include #include #define MAX 10using namespace std;class Myclass{private: vector vel;...
阅读全文