数据结构
weixin_54042669
热爱生活的coder~ 公众号:码农小家园
展开
-
冒泡排序(C++)
#include"iostream"using namespace std;void Swap(int &a,int &b){ int temp = a; a = b; b = temp;}void Bubble_Sort(int a[],int n){ for (int p = n - 1; p > 0; p--) { int flag = 0; for (int i = 0; i < p; i++) { if (a[i] > a.原创 2021-08-05 15:54:10 · 77 阅读 · 0 评论 -
循环队列C++实现
#include"iostream"using namespace std;#define OK 1#define ERROR 0#define MAXQSIZE 100typedef struct{ int *base; int front; int rear;}SqQueue;int InitQueue(SqQueue &Q){ Q.base = new int[MAXQSIZE]; if (!Q.base) exit(OVERFLOW); Q.front =.原创 2021-07-23 17:49:37 · 112 阅读 · 0 评论 -
链栈的实现
#include"iostream"using namespace std;#define OK 1#define ERROR 0typedef struct StackNode{ int data; struct StackNode *next;}StackNode,*LinkStack;int InitStack(LinkStack &s){ s = NULL; return OK;}int Push(LinkStack &s,int e){ LinkS.原创 2021-07-23 16:14:15 · 104 阅读 · 0 评论 -
顺序栈的实现
#include"iostream"using namespace std;#define OK 1#define ERROR 0#define MAXSIZE 100typedef struct{ int *base; int *top; int stacksize;}SqStack;int InitStack(SqStack &s){ s.base = new int[MAXSIZE]; if (!s.base) exit(OVERFLOW); s.top =.原创 2021-07-23 15:54:56 · 82 阅读 · 0 评论 -
线性表的合并
#include"iostream"using namespace std;#define MAXSIZE 100typedef struct{ int *elem; int length;}Sqlist;void InitList(Sqlist &l,int n){ l.elem = new int[MAXSIZE]; l.length = n; for (int i = 0; i < n; i++) cin >> l.elem[i];}bool.原创 2021-07-10 21:15:24 · 98 阅读 · 0 评论 -
顺序表的操作及实现(C++)
顺序表的操作是大家在学习数据结构的第一个模块,也是最简单的一个。下列是顺序表的六种基本操作详解,希望能对您有所帮助~1.建立一个顺序表,输入n个元素并输出#define MAXSIZE 100//确定最大值#define OK 1#define ERROR 0typedef struct//自定义顺序表类型{ int *elem; int length;}sqlist;int InitList(sqlist &l){ l.elem = new int[MAXSIZE];原创 2021-07-05 22:13:21 · 2844 阅读 · 0 评论