c++数据结构
秃鹫红发夜魔王
哈哈哈
展开
-
栈的链式存储
LinkStack.cpp#include "LinkStack.h"#include<stdio.h>#include<stdlib.h>LinkStack *Init_LinkStack(){ LinkStack *stack = (LinkStack*)malloc(sizeof(LinkStack)); stack->head.next = NUL...原创 2018-09-30 21:29:12 · 219 阅读 · 0 评论 -
快速排序
#define _CRT_SECURE_NO_WARNINGS#include<iostream>using namespace std;void PrintArray(int arr[], int len){ for (int i = 0; i < len; i++) { cout << arr[i] <<""; } cout <...原创 2018-10-08 22:25:16 · 146 阅读 · 0 评论 -
栈的应用_就近匹配(基于栈的顺序存储)
#define _CRT_NO_SECURE_WANRINGS#include "SeqStack.h"#include<stdio.h>#include<stdlib.h>int main(void){ SeqStack*stack =Init_SeqStack(); char *str = "1+5+(dsf)gahdah()f("; cha...原创 2018-09-29 15:58:29 · 161 阅读 · 0 评论 -
希尔排序
//分组 插入排序//先分组 然后对每一组分别进行插入排序//合组 然后再插入排序//分组增量是:increasement/3+1#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<string.h>#include<sys/timeb.h&g...原创 2018-10-08 15:50:00 · 131 阅读 · 0 评论 -
数组应用(Z字形编排问题)
#include<iostream>#include<iomanip>using namespace std;#define SIZE 8int main(int argc, char**argv) { int maxtrix[SIZE][SIZE] = { 0 }; int a[SIZE][SIZE] = { 0 }; int *p = NULL; p ...原创 2018-10-14 20:21:45 · 513 阅读 · 0 评论 -
插入排序
#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<string.h>#include<sys/timeb.h>#include<time.h>#define MAX 10long getSystemTime(){ struc...原创 2018-10-08 09:14:55 · 167 阅读 · 0 评论 -
二叉树非递归遍历思路
1.将树的结点与一个FALSE标志位合一起压栈2.判断栈中元素个数是否为空3.栈顶元素出栈,将其标志位变成TRUE,同时将其左右树结点与FALSE标志位合一起压栈。#define _CRT_SECURE_NO_WARNINGS#include&lt;stdio.h&gt;#include&lt;stdlib.h&gt;#include&lt;string.h&gt;#include .原创 2018-10-06 16:10:11 · 730 阅读 · 0 评论 -
栈的顺序存储
SeqStack.cpp#include "SeqStack.h"#include<stdio.h>#include<stdlib.h>typedef struct PERSON{ char name[64]; int age;}Person;int main(void){ //创建栈 SeqStack *stack = Init_SeqStack()...原创 2018-09-28 09:43:17 · 151 阅读 · 0 评论 -
最大连续子序列之和问题(O(n*n)
#include<iostream>#include<stdlib.h>using namespace std;int MaxSubsequenceSum(int a[],int length){ int MaxSum = 0; int ThisSum,SeqStart,SeqEnd; for (int i = 0; i < length; i++) ...原创 2018-10-12 15:41:18 · 403 阅读 · 0 评论 -
二叉树编程实战_求叶子节点数目
统计二叉树中叶子结点的个数:叶子节点:没有孩子节点的树demo.cpp#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<string>//二叉树结点typedef struct BINARYNODE{ char ch; struct BINAR...原创 2018-10-04 19:36:01 · 814 阅读 · 0 评论 -
树的遍历:
如上图所示:先序遍历(DLR):先访问根 再访问左 再就是右:ABCDEFGH中序遍历(LDR):先左再根再右:BDCCEAFHG后序遍历(LRD):先左再右再根:DECBHGFA递归遍历(先序遍历):#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include&...原创 2018-10-04 15:15:30 · 171 阅读 · 0 评论 -
字符串排序
#include<stdio.h>#include<string>#include<iostream>using namespace std;int main(void){ string str[] = { "abc", "ac", "c", "abcd" }; int length = sizeof(str) / sizeof(st原创 2018-10-11 22:01:15 · 169 阅读 · 0 评论 -
栈的应用_后缀表达式的求解
后缀表达式的由来,请看资源:https://blog.csdn.net/qq_23859701/article/details/82918771现在是后缀表达式的求解:demo.cpp#define _CRT_SECURE_NO_WARNINGS#include<stdio.h>#include<stdlib.h>#include<string.h>...原创 2018-10-02 15:33:40 · 242 阅读 · 0 评论 -
中缀表达式转后缀表达式
理论知识demo.cpp#define _CRT_SECURE_NO_WARNINGS#include "LinkStack.h"#include&lt;stdio.h&gt;#include&lt;stdlib.h&gt;#include&lt;string&gt;//是否是数字int IsNumber(char c){ retur原创 2018-10-01 21:19:29 · 196 阅读 · 0 评论 -
归并排序
#define _CRT_SECURE_NO_WARNINGS#include<iostream>#include<time.h>using namespace std;#define MAX 10int* CreateArray(){ int *arr = (int*)malloc(sizeof(int)*MAX); srand((unsigned int...原创 2018-10-09 15:56:39 · 173 阅读 · 0 评论