自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(12)
  • 收藏
  • 关注

原创 TSP(分支限界法)

#include<bits/stdc++.h>#define INF 60000#define n 4using namespace std;int** a;int bestc = INF;int* bestx;int* minout;int sum_minout;class Node{public: int t_; int ccost_; int least_cost_; int* x_;public: void Init_Nod

2020-12-29 11:58:44 1694

原创 图的m涂色问题(回溯法)

#include<bits/stdc++.h>using namespace std;class Color{private: int n_;//顶点数 int m_;//颜色数 int **Martix;//邻接矩阵 int *x; //当前解 int solution_num_; //解的个数 bool OK(int k); //判断第k个涂色是否与前边的涂色冲突 void Backtrack(int

2020-12-24 21:31:15 458

原创 回溯法解决0-1背包问题(迭代)

#include<bits/stdc++.h>using namespace std;class Knap{ friend int Knapsack(int*,int*,int,int,Knap&);public: int c; int n; int* w; int* p; int cw; int cp; int bestp; int *x, //当前解 *bestx; //当前最优解

2020-12-22 15:56:48 1327 5

原创 回溯法解决0-1背包问题(递归)

#include<bits/stdc++.h>using namespace std;class Knap{ friend int Knapsack(int*,int*,int,int);private: int c; int n; int* w; int* p; int cw; int cp; int bestp; int Bound(int i); void Backtrack(int i);};int

2020-12-20 15:45:14 652

原创 二分查找递归非递归实现(分治法)

#include<bits/stdc++.h>using namespace std;/*初始化数组*/int Init_Array(int* & a){ cout<<"请输入数组大小"<<endl; int n; cin>>n; a = new int [n]; cout<<"请输入数组元素(保证输入为有序数组)"<<endl; for(int i=0;i<n;i+

2020-12-16 10:57:43 329

原创 0-1背包问题(动态规划)

#include<bits/stdc++.h>#define n 5#define capacity 10using namespace std;int w[n+1] = {-1,2,2,6,5,4};int v[n+1] = {-1,6,3,5,4,6};int m[n+1][capacity+1];int x[n+1];int min(int a,int b){ if(a<b) return a; return b;}int max(int a,int b)

2020-12-16 10:55:43 90

原创 独立最优任务调度(动态规划)

#include<bits/stdc++.h>#define n 6#define suma 31#define maxtime 10000using namespace std;int a[n+1] = {-1,2,5,7,10,5,2};int b[n+1] = {-1,3,8,4,11,3,4};int f[n+1][suma+1];int min(int a,int b){ if(a<b) return a; return b;}int max(int

2020-12-16 10:54:36 351

原创 棋盘覆盖问题(分治法)

#include<bits/stdc++.h>using namespace std;int board[10000][10000];int tile = 1;void ChessBoard(int tr,int tc,int dr,int dc,int size_){ if(size_ == 1) return ; int t = tile++; int s = size_ / 2; //填充左上角 if(dr < tr+s

2020-12-16 10:52:59 234

原创 构造哈夫曼编码(贪心思想)

#include<bits/stdc++.h>#define char_num 6using namespace std;typedef struct Tree{ string name_; int weight_; struct Tree* left, *right;}*BinTree;struct cmp{ bool operator()(const BinTree& a,const BinTree& b){ return a-&gt

2020-12-16 10:51:17 236

原创 单链表尾插法(顺序插入)

尾插法实质上是始终使新构造的结点插入到上一个构造的结点和NULL之间而头插法是使其始终插入在头节点和上一个构造的结点之间

2020-11-15 20:50:47 510

原创 单链表的头插法(倒叙插入)基于先构造头节点

#include<bits/stdc++.h>using namespace std;//链表typedef struct LNode{ int data; struct LNode* next;}* LinkList;void CreateList_L(LinkList& L){ int input; L =(struct LNode*)malloc(sizeof(LNode)); L->next = NULL; Li

2020-11-15 20:45:46 242

原创 单链表倒叙插入(基于先构造尾部的思路)

#include<bits/stdc++.h>using namespace std;//链表typedef struct LNode{ int data; struct LNode* next;}* LinkList;void CreateList_L(LinkList& L, int n){ int sumn = n; LinkList p = NULL; while(n--) { LinkList te

2020-11-15 17:48:01 111

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除