- 博客(11)
- 资源 (2)
- 收藏
- 关注
原创 经典01背包问题
#include <iostream>using namespace std;int n;int c[100][100];int w[100],v[100],x[100];void aaa(int n,int m){ int i,j; for(i=0;i<=m;i++) c[0][i]=0; for(i=1;i<=n;i++) { c[i][0]...
2018-06-10 17:26:30
206
原创 贪心算法之活动安排
#include<iostream>using namespace std;struct data{ int s, f, key;};void atime(int n, data *x, int *a){ a[0] = 1; int j = 0, i; for (i = 1; i < n; i++) { if (x[i].s >= x[j].f)...
2018-06-10 17:25:29
502
原创 整数划分
#include<stdio.h> void main(){ int equation(int n,int m); int n,m; printf("Please input 'n'(0<n<100):"); scanf("%d",&n); printf("Please input 'm'(0<m<=n):&quo
2018-06-10 17:24:14
147
原创 最优二叉树
#include <iostream>using namespace std;int n;int *a, *b, **s, **w, **m;void bost(int *b, int *a, int **w, int **m, int **s){ int i,j,k,r,t; for (i = 0; i <= n; i++) { w[i + 1][i...
2018-06-10 17:21:37
488
原创 数据结构 链栈的基本操作
链栈#include #include#include using namespace std;typedef struct selemtype{ selemtype *next; int data;}selemtype;selemtype *initstack(){ selemtype *top; top = (selemtype *)malloc(sizeof(se
2016-12-13 21:16:45
527
原创 数据结构 串的堆分配及基本操作
堆分配#include #include #include using namespace std;#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define INFEASIBLE -1#define OVERFLOW -2typedef struct{ char *ch; int length;}
2016-12-13 21:13:23
1193
原创 c++中重载运算符来实现2*3矩阵相加
矩阵相加#include using namespace std;class aaa{ private: int a[2][3]; public: friend aaa operator+(aaa&A,aaa&B); friend ostream& operator<<(ostream&,aaa&); friend istream& operator>>(istre
2016-12-13 21:10:44
3832
原创 数据结构图的基本操作--邻接表法(不包括深度、广度算法)
基本操作代码如下#include #include using namespace std; #define MAX_VERTEX_NUM 20#define ERROR -1int visited[10000];typedef struct arcnode//结点的组成域{ int adjvex; struct arcnode *nextarc;//指向下一条弧的指针 i
2016-12-11 21:18:53
408
原创 Huffman树的创建
Huffman树,又称最优树,是一类带权路径长度最短的树。在解决某些判定问题时,Huffman树可#include #include using namespace std;#define MAXBIT 20#define MAXLEAF 30#define MAXNODE 59typedef struct{ int bit[MAXBIT]; int
2016-12-11 21:15:25
466
原创 定长顺序串的基本操作
定长顺序串采用的是数组方法进行存储,空间分配一次完成,可以实行如下的基本操作#include #include using namespace std;#define MAXSTRLEN 200#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define INFEASIBLE -1#define OVERFL
2016-12-11 21:12:15
5473
原创 定长顺序串的kmp算法
#include #include using namespace std;#define MAXSTRLEN 200#define TRUE 1#define FALSE 0#define OK 1#define ERROR 0#define INFEASIBLE -1#define OVERFLOW -2typedef unsigned char ss
2016-12-11 20:57:56
850
空空如也
TA创建的收藏夹 TA关注的收藏夹
TA关注的人