自定义博客皮肤VIP专享

*博客头图:

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

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

博客底图:

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

栏目图:

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

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

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

原创 c++实现回溯算法背包问题

c++实现回溯算法背包问题#include <iostream>using namespace std;int weight[4] = { 1,2,3,4 };int value[4] = { 3,2,4,3 };int flag[4] = { 0 };int maxvalue = 0;int packweight = 0;int packvalue = 0;void backtrack(int node){ if (node == 4) { if (maxvalue

2021-01-28 10:54:51 186

原创 c++实现广度搜索

c++实现广度搜索#include <iostream>#include<queue>using namespace std;class graph{public: int data[10][10]; int flag[10]; int t = 1; queue<int>q; graph() { for (int i = 0; i < 10; i++) { for (int j = 0; j < 10; j++) {

2021-01-27 16:59:06 203

原创 c++实现深度优先搜索

c++实现深度优先搜索#include<iostream>#include<stack>using namespace std;int flag[10] = { 0 };//判断该点是否已经访问int m[10][10] = { 0 };//点之间的关系void DFS(int node){ stack<int>s; if (flag[node] == 0) { flag[node]++; cout << node <<

2021-01-27 11:39:32 249

原创 c++实现Dijkstra

c++实现Dijkstra#include <iostream>#include<algorithm>using namespace std;int main(){ int vex[4] = {0}; int path[4] = { 0 }; int data[4][4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i == j) { da

2021-01-24 17:01:43 95

原创 c++实现floyd算法

c++实现floyd算法#include <iostream>#include<algorithm>using namespace std;int main(){ int data[4][4]; for (int i = 0; i < 4; i++) { for (int j = 0; j < 4; j++) { if (i == j) { data[i][j] = 0; } else { data[

2021-01-24 10:53:23 115

原创 动态规划0/1背包

动态规划0/1背包#include <iostream>#include<algorithm>#include<math.h>using namespace std;int main(){ int weight[] = { 1,2,3,4,1,2 }; int value[] = { 1,3,2,5,4,2 }; int pack = 8; int data[7][9]; for (int i = 0; i < 7; i++) { dat

2021-01-23 16:42:25 75

原创 c++实现快速排序

c++实现快速排序#include <iostream>using namespace std;void quick(int left, int right, int*data){ if (left >= right) { return; } int temp = data[left]; int i = left; int j = right; while (i != j) { while(data[j] >= temp&&j>i

2021-01-23 11:17:42 103 1

原创 c++实现归并排序

c++实现归并排序#include <iostream>using namespace std;void merge(int start, int end, int* data){ int result[100]; int leftlength = (end-start)/2+1; int leftindex = start; int rightindex = leftlength + start; int resultindex = start; while (leftin

2021-01-22 16:36:39 79

原创 c++ 实现邻接矩阵

c++ 实现邻接矩阵代码如下#include <iostream>#include<vector>using namespace std;class Graph{public: int vexs[100]; int edges[100][100]; int vex; int edge; Graph() { for (int i = 0; i < 100; i++) { vexs[i] = 0; } for (int i = 0;

2021-01-21 16:53:47 992

原创 c++实现AVL树左旋

c++实现AVL树的左旋在这里插入代码片#include"pch.h"#include<iostream>#include<math.h>#include<string>#include<algorithm>using namespace std;class Node{public: Node* leftnode; Node* rightnode; int value; int height; Node() { leftnod

2021-01-20 17:23:27 137 2

原创 c++实现二叉树

c++实现二叉树#include"pch.h"#includeusing namespace std;class Node{public:Node* leftnode;Node* rightnode;int value;Node(){leftnode = NULL;rightnode = NULL;value = 0;}void add(int v){if (value == 0){value = v;}else{if (value >= v){if

2021-01-19 18:25:12 72

空空如也

空空如也

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

TA关注的人

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