![](https://img-blog.csdnimg.cn/20201014180756780.png?x-oss-process=image/resize,m_fixed,h_64,w_64)
数据结构
数据结构课程实现代码
xy66
这个作者很懒,什么都没留下…
展开
-
折半查找(数组)
#include<iostream> using namespace std; int Search(int n[],int s) { int low = 0, high = 9, mid; while (low <= high) { mid = (low + high) / 2; if (n[mid] == s) return mid; else if (n[mid] > s) high = mid - 1; else low = mid原创 2022-05-26 15:27:34 · 67 阅读 · 0 评论 -
图的定义,遍历操作
#include<iostream> #define MaxVertexNum 100 using namespace std; typedef struct { char Vex[MaxVertexNum];//顶点表 int Edge[MaxVertexNum][MaxVertexNum];//邻接矩阵 int vexnum, arcnum;//顶点数,弧数 }MGraph; typedef struct ArcNode {//边表结点 int adjvex;//弧指向顶点的原创 2022-05-26 10:43:18 · 51 阅读 · 0 评论 -
栈的遍历(递归)
#include<iostream> #define MaxSize 50 using namespace std; typedef struct BiTNode { int data; struct BiTNode* lchild, * rchild; }BiTNode,*BiTree; typedef struct Queue { int front, rear; int data[MaxSize]; }Queue; void visit(BiTNode* T); void Init原创 2022-05-26 09:36:54 · 592 阅读 · 0 评论 -
栈的括号匹配
#include<iostream> #define MaxSize 50 using namespace std; typedef struct { char data[MaxSize]; int top; }SqStack; void InitStack(SqStack& S) { S.top = -1; } bool Push(SqStack& S,char x) { if (S.top == MaxSize - 1) return false; S.da原创 2022-05-13 18:43:23 · 76 阅读 · 0 评论 -
循环队列基本操作
#include<iostream> #define MaxSize 50 using namespace std; typedef struct { int data[MaxSize]; int front, rear; }SqQueue; void InitQueue(SqQueue& Q) { Q.rear = Q.front = 0; } bool isEmpty(SqQueue& Q) { if (Q.rear = Q.front) return true原创 2022-05-13 10:33:04 · 63 阅读 · 0 评论 -
顺序栈基本操作
#include<iostream> #define MaxSize 50 using namespace std; typedef struct { int data[MaxSize]; int top; }SqStack; void InitStack(SqStack& S) { S.top = -1; } bool StackEmpty(SqStack& S) { if (S.top == -1) return true; else return fals原创 2022-04-29 18:58:07 · 56 阅读 · 0 评论 -
链表基本操作
#include<iostream> using namespace std; typedef struct LNode { int data; struct LNode* next; }LNode,*LinkList; //带头结点头插法 LinkList HeadInSert(LinkList& L) { LNode* p; int x; cin >> x; L = (LinkList)malloc(sizeof(LNode)); L->next原创 2022-04-29 11:18:40 · 499 阅读 · 0 评论 -
顺序表基本操作
#include<iostream> #define MaxSize 50 using namespace std; typedef int Elemtype; typedef struct { int data[MaxSize]; int length; }SqList; void InitList(SqList& L) { for (int i = 0; i < MaxSize; i++) L.data[i] = 0; L.length = 0; } void原创 2022-04-29 11:17:30 · 47 阅读 · 0 评论 -
一元多项式表示相加
例子: A=7+3x+9x8+5x17A = 7+3x+9x^8+5x^17 A=7+3x+9x8+5x17 B=8x+22x7−9x8B = 8x+22x^7-9x^8 B=8x+22x7−9x8 #include <iostream> #include <malloc.h> using namespace std; typedef struct Term { float coef;//x前面的系数 int expn; //x的次方数 struct Term *next; }转载 2021-10-05 23:04:37 · 83 阅读 · 0 评论