随笔分类 - 基础算法
如题
摘要:#include<iostream> #define N 5 using namespace std; //回溯法实现N皇后问题 void place(int* x,int n){ for(int i=1;i<N;++i){ int ifPlace=1; for(int j=1;j<N;++j) i
阅读全文
摘要:#include<iostream> using namespace std; //动态规划实现0-1背包客问题 #define C 40 #define MYNUM 10//第0个不算物品,实际有n-1个物品 int m[MYNUM][C]; typedef struct{ int w,v; }E
阅读全文
摘要:#include<iostream> #include<Windows.h> using namespace std; //锦标赛算法求第二大的数(不考虑数组中存在多数等值情况下) typedef struct LNode{ int data; struct LNode *next; }LNode,
阅读全文