数据结构
for_casech
小人物
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
算法 排序 快排
#include #include void mysort(int *a, int low, int m) { int shang = low; int xia = m; int temp = a[shang]; while (shang < xia) { while (shang temp) xia--; a[shang] = a[xia]; while原创 2016-02-27 00:41:04 · 276 阅读 · 0 评论 -
算法排序 归并 理解性写
#include using namespace std; void myswap(int a[],int l,int m,int r,int *&b) { int p = 0; int i=l, j = m + 1; while (i <= m&&j <= r) { if (a[i] < a[j]) { b[p++] = a[i++]; } else原创 2016-02-27 00:43:07 · 287 阅读 · 0 评论 -
好久没有复习数据结构了 简单复习树转双链表
创建一个结构体 C语言风格 写起来比较舒服 void CreateBitree(BsTreeNode * &pRoot,int * &arr); void change(BsTreeNode * node,BsTreeNode * &pTail); struct BsTreenode { int m_value; BsTreenode *m_left; BsTreenode *m原创 2016-06-19 18:57:07 · 304 阅读 · 0 评论 -
检测树是否后续便利
using namespace std; bool isPostTreeTraversal(int arr[],int leng) { if (leng <= 0 || NULL == arr) { return false; } int root = arr[leng - 1]; int m = 0; for (; m < leng - 1; m++) { if (arr原创 2016-06-19 19:08:15 · 329 阅读 · 0 评论 -
求1+2+3+n后的结果
class Sum { public: Sum() { num++; sum+=num; } int getSum(){return sum;} static int num; static int sum; } int Sum::num=0; int Sum::sum=0; void main() { Sum *p=new Sum[100]; delete []p; cout<<原创 2016-06-19 19:43:36 · 508 阅读 · 0 评论 -
求数组不小于0的和
数组有比如 1 -2 3 -4 5 6 -5 9 1+(-2)为小于1 不求和进行重置 5+6-5 =6 +9 上手敲了不在编译器上敲在粘贴了 int SumMaxSub(int arr[],int len) { int sum=0,temp=0; for(int i=0;i { if(temp原创 2016-06-19 19:55:52 · 370 阅读 · 0 评论 -
树左孩子 于右孩子交换
8 8 / \ 转换 / \ 6 10 --> 10 6 / \ / \ / \ / \ 5 7 9 11 11 9 7 5 #include using namespa原创 2016-06-19 20:29:18 · 393 阅读 · 0 评论 -
求list倒数value
#include using namespace std; struct ListNode { int m_lvaue; ListNode*m_next; ListNode() { m_lvaue = 0; m_next = NULL; } }; void createListNode(ListNode*&node,int *&arr,int len,int fitstr原创 2016-06-20 14:04:22 · 488 阅读 · 0 评论 -
List逆转
void ReveseListNodes(ListNode *&node) { if (!node || !node->m_next) return; ListNode *p = node; ListNode*pp = p; ListNode*ppp = NULL; while (p) { pp = p; p = p->m_next; pp->m_next = ppp;原创 2016-06-20 17:12:25 · 264 阅读 · 0 评论 -
刚学C语言时理解性的写的2杈
#ifndef _SHU_H #define _SHU_H #define _CRT_SECURE_NO_WARNINGS #include #include #include #include typedef struct Node//树 { int data; struct Node *you; struct Node *zuo; }node,*N; typedef struc原创 2016-02-26 23:01:44 · 314 阅读 · 0 评论 -
学C++第一天 面向对象写2杈
此时此刻没有学到数据结构这块 所以 思想还是停留在C 的坑 #include using namespace std; class data { public: data(int i):x(i){} virtual ~data(){ cout << "data.....\n"; } virtual void pint() = 0; int getvalue(){ return原创 2016-02-26 23:11:14 · 406 阅读 · 0 评论 -
C++数据结构 乱搭配模板迭代
#include #include #include using namespace std; template class stack { private: class s { private: T *data; s * zuo; s *you; public: s() :data(0), next(0){} s(T*da):data(da),zuo(0),y原创 2016-02-26 23:33:04 · 333 阅读 · 0 评论 -
参考书本 背包问题
#define _CRT_SECURE_NO_WARNINGS #include #include int x[100] = { 0 }; //数组X用来存放路径 int val[100] = { -1 };//物品单价 int weight[100] = { -1 };//存放物品的重量 int isOverLoad(int n, int c) { int i, w = 0原创 2016-02-27 00:36:43 · 374 阅读 · 0 评论 -
c 数据算法参考书本 跳斑马
#include #include #define X 8 #define Y 8 int chess[X][Y]; int nextxy(int *x, int *y, int conut) { switch (conut) { case 0: if (*x + 2 = 0 && chess[*x + 2][*y - 1] == 0) { *x = *x + 2;转载 2016-02-27 00:35:25 · 355 阅读 · 0 评论 -
C++ 2杈树 完整
#ifndef RB_H_ #define RB_H_ #include #include template class RB; template class Node { friend RB; private: Node() :zuo(0), you(0),data(0){} Node(T *&s):data(s),zuo(0),you(0){} ~Node(){ delete原创 2016-02-27 00:21:48 · 371 阅读 · 0 评论 -
C++ 红黑树
#ifndef WRAPPER_H #define WRAPPER_H #include "Except.h" template class Cref { public: Cref() :obj(NULL){} explicit Cref(const Objct &x) :obj(&x){} const Objct &get()const { if (usNull())throw N原创 2016-02-27 00:14:55 · 371 阅读 · 0 评论 -
C++ 酒桶算法
template int maxlen(T *data,const int n) { int p = 10; int d = 0; for (int i = 0; i < n; i++) { while (data[i] >= p) { p *= 10; ++d; } } return d; } template void readsort(T data[],原创 2016-02-27 00:06:11 · 737 阅读 · 0 评论 -
C 语言算法排序 希尔
#include #include #include void shellsort(unsigned int k[], int xia) { int i; int j; int flag; int zhong = xia; int tmp; while (zhong > 1) { zhong = zhong / 2; do { flag = 0; for (i原创 2016-02-26 23:57:44 · 301 阅读 · 0 评论 -
C 数据算法 八皇后
#define _CRT_SECURE_NO_WARNINGS #include using namespace std; int a[8];int c = 0; int n = 4; bool flag(int pos) { int i; for (i = 0; i < pos; ++i) { if (a[i] == a[pos]) { return false; }原创 2016-02-26 23:38:45 · 294 阅读 · 0 评论 -
C++数据结构 简单栈 (一贯作风::懒)
#include #include #include using namespace std; template class stack { public: stack() :head(0), end(0),top(0){} void Push(T *d); T *Pop(); int len(){ return top; } ~stack() { while (hea原创 2016-02-26 23:35:19 · 343 阅读 · 0 评论 -
汉罗塔非递归
/*汉诺塔递归和非递归算法实现*/ #include using namespace std; typedef struct Tower{ int height; char a,b,c; }Tower; typedef struct Node{ Tower element; Node* pNext; }Node,*LinkList; typedef struct原创 2016-06-23 12:56:07 · 847 阅读 · 0 评论
分享