数据结构
Gtl722
这个作者很懒,什么都没留下…
展开
-
数据结构—括号匹配
/* 栈的应用:括号配对*/#include<iostream>#include<stack>#include<string.h>using namespace std;void MatchBracket(char* S) { stack<char> stack; int length = strlen(S); for (int i = 0; i < length; i++) { if (S[i] == '(' || S[i]原创 2020-05-22 11:19:44 · 415 阅读 · 0 评论 -
数据结构—判断回文数
/* 栈的基本应用:判断回文数*/#include<iostream>#include<cstring>#include<malloc.h>#include<stdlib.h>#define STACK_INIT_SIZE 100 //存储空间初始分配量 #define STACK_INCREASEMENT 10using namespace std;typedef struct { char* base; char* top;原创 2020-05-22 08:28:16 · 1068 阅读 · 1 评论 -
数据结构—进制转换
/* 栈的基本应用:进制转换*/#include<iostream>#include<malloc.h>#include<stdio.h>#define STACK_INIT_SIZE 100 //存储空间初始分配量 #define STACK_INCRESEMENT 10using namespace std;typedef struct { int* base; int* top; int stacksize;//当前已经分配的存储空间}原创 2020-05-21 20:34:59 · 5000 阅读 · 0 评论 -
数据结构—顺序栈
/* 顺序栈的基本操作 栈空条件:S.base == S.top 栈中元素个数:S.top - S.base*/#include<iostream>#include<malloc.h>#include<stdlib.h>#define STACK_INIT_SIZE 50 //栈的初始大小#define STACK_INCREASEMENT 10 //栈的大小的增量using namespace std;typedef int ElemType; /原创 2020-05-21 19:56:35 · 430 阅读 · 0 评论 -
链表操作—单链表的销毁与清空
/* 单链表的销毁与清空 销毁:连同头结点一起释放 清空:保留头结点;置头结点的指针域为NULL*///销毁链表void destroyList(Linklist &L) { Linklist p; p = L; while (p) { L = L->next;// free(p); delete(p); }}//清空链表void clearList(Linklist &L) { Linklist p; while (L->next)原创 2020-05-17 13:44:53 · 14209 阅读 · 8 评论 -
链表操作—头插法尾插法
单链表的插入操作,包括头插和尾插,两种的时间复杂度都为O(n)。/* 单链表插入操作(头插+尾插)*/#include<iostream>#include<malloc.h>#include<stdlib.h>using namespace std;//定义结点数据类型typedef int Elemtype;//结点定义typedef struct LNode { Elemtype data; LNode* next;}LNode, *原创 2020-05-17 13:03:21 · 1615 阅读 · 0 评论 -
链表操作—单链表的倒置
链表操作—单链表的倒置代码:/* 单链表的倒置*/#include<iostream>#include<malloc.h>#include<stdlib.h>using namespace std;//定义结点数据类型typedef int Elemtype;//结点定义typedef struct LNode { Elemtype data; LNode* next;}LNode, * Linklist;//创建单链表(头插法)voi原创 2020-05-17 12:09:58 · 1314 阅读 · 0 评论