![](https://img-blog.csdnimg.cn/20190918140158853.png?x-oss-process=image/resize,m_fixed,h_224,w_224)
链栈列树
文章平均质量分 78
有.难
WAWA战士
起飞
展开
-
18448 最小生成树
思路:贪心!!!!,把到当前树的距离最小的点不断收录到树中,树在扩大的同时,我们要更新树外的点到树的距离,最终整体最小 #include<iostream> #include<cstring> #include<algorithm> using namespace std; int map[50][50]; int dis[50];//表示每一个点到 当前最小生成树 的距离,如dis[6]就是6号节点到当前最小生成树的距离 bool istree[50];//true原创 2020-06-04 21:50:51 · 387 阅读 · 0 评论 -
8609 哈夫曼树
#include <cstdio> #include <malloc.h> #include <cstring> #include <algorithm> #include <iostream> using namespace std; typedef struct{ int weight; int parent,lchild,rchild; }HTNode,*HuffmanTree; typedef char **HuffmanC原创 2020-05-28 16:44:47 · 224 阅读 · 0 评论 -
8608 实现二叉排序树的各种算法(2)
#include<iostream> #include<malloc.h> #include<stack> #include<queue> #include<algorithm> using namespace std; typedef struct tree { int data; struct tree *lchild,*rchild; }node,*bst; void grow(bst &t,int data)//原创 2020-05-18 20:20:02 · 1164 阅读 · 0 评论 -
8607 实现二叉排序树的各种算法(1)
#include<iostream> using namespace std; int a[200]; typedef struct node//二叉排序树结构体 { int data; struct node *lchild,*rchild; }node,*bst; typedef struct//队列结构体 { bst *base; int he...原创 2020-05-07 01:00:12 · 997 阅读 · 0 评论 -
8606 二叉树的构建及遍历操作
注意顺序就完事 #include "cstdio" #include "iostream" #include "malloc.h" using namespace std; typedef char ElemType; typedef struct BiTNode{ ElemType data; struct BiTNode *lchild,*rchild;//左右孩子指针 } BiT...原创 2020-05-04 18:04:16 · 436 阅读 · 0 评论 -
8590 队列的应用——银行客户平均等待时间
思路:首先用一个cur用来表示上一位顾客完成业务办理的时刻, 第一种情况: 如果当前顾客的到达时刻 cli [i] [0] 小于这个cur,那就说明他必须要等上一位顾客搞定才轮得到他,这个cur减 cli [i] [0] 就能得到当前顾客的等待时间, 第二种情况: 如果当前顾客的到达时刻 cli [i] [0] 大于这个cur,说明他根本不用等,因为上一个顾客搞完很久了,这时候相当于当前顾客是第一...原创 2020-05-03 12:58:02 · 930 阅读 · 0 评论 -
8588 表达式求值
思路: 输入操作符优先级表,定义好四则运算操作符的运算,注意使用标记法记录是否为多位数运算, 注意:过程中发现cout很智能,我输入5.1输出5.1,输入5.100输出5.1,输入5输出5,这确实很奇特,自动完成舍弃多余数字 本文原作者 #include<iostream> #include<cstring> #include<cstdio> #inc...转载 2020-04-30 14:47:36 · 1131 阅读 · 0 评论 -
8585 栈的应用——进制转换
注意: 写这个的时候有点忘记栈和队列的区别了, 栈的base是作为数组首地址的,因为栈只在顶部进进出出,所以说没有必要重新开一个指针数组, 相反,队列头出尾进,两边都要用,所以我们不得不开一个指针数组elem来专门存放数据,另外分别定义首尾位置指示器, 还有一点就是循环队列其实是队列的一种较优的实现方式 #include<malloc.h> #include<iostream&g...原创 2020-04-29 21:15:23 · 457 阅读 · 0 评论 -
8584 循环队列的基本操作
注意:循环队列取模很重要 #include<malloc.h> #include<stdio.h> #define OK 1 #define ERROR 0 typedef int Status; // Status是函数的类型,其值是函数结果状态代码,如OK等 typedef int QElemType; #define MAXQSIZE 100 // 最大队列长度(对于...原创 2020-04-29 20:25:53 · 339 阅读 · 0 评论 -
8583 顺序栈的基本操作
#include<malloc.h> #include<stdio.h> #define OK 1 #define ERROR 0 #define STACK_INIT_SIZE 100 // 存储空间初始分配量 #define STACKINCREMENT 10 // 存储空间分配增量 typedef int SElemType; // 定义栈元素类型 typedef ...原创 2020-04-29 14:29:30 · 710 阅读 · 0 评论 -
8581 线性链表逆置
思路: 弄三个指针分别是pre,cur,rear,指向前驱结点,当前修改节点,后驱结点,每次修改cur的next指向pre,然后当前的pre指向当前的cur,cur指向rear,rear指向下一个,实现了链表遍历 #include<iostream> #include<cstdio> using namespace std; typedef struct node { ...原创 2020-04-29 13:11:37 · 355 阅读 · 0 评论 -
8580 合并链表
#include<iostream> #include<cstdio> using namespace std; typedef struct node { int data; struct node *next; }node,*list; void merge(list &a,list &b,list &c) { lis...原创 2020-04-28 21:40:16 · 269 阅读 · 0 评论 -
火车进站(栈,模拟)
提示:本文有一点啰嗦 思路: 模拟这个过程,我们拿3 2 4 1 6 5举例 首先pop出去的是3,那么当前栈中剩下的就应该如下 2 1 即从1开始push一直到3,然后就pop掉3了, 好,我们现在看到2, 2比3小,那么必然在栈中,而且一定是位于栈顶 因为我们是不断+1这样叠上去的,所以说一旦pop出来的小于上一个数字,那么他必然是栈的数字中距离上一个数字最近的一个呀, 即3才刚刚pop了出去...原创 2020-04-17 17:45:43 · 593 阅读 · 0 评论 -
8579 链式线性表的基本操作(链表)
#include<stdio.h> #include<malloc.h> #define ERROR 0 #define OK 1 #define ElemType int #include<iostream> using namespace std; typedef struct LNode { int data; struct LNode *next; ...原创 2020-03-18 17:37:33 · 1236 阅读 · 1 评论 -
8578 顺序表逆置(顺序表)
#include<iostream> #include<malloc.h> #define OK 1 #define ERROR 0 #define LIST_INIT_SIZE 100 #define LISTINCREMENT 10 #define ElemType int using namespace std; typedef int Status; typedef...原创 2020-03-18 15:23:24 · 1230 阅读 · 0 评论 -
8577 合并顺序表(顺序表)
#include<iostream> #include<malloc.h> #define OK 1 #define ERROR 0 #define LIST_INIT_SIZE 100 #define LISTINCREMENT 10 #define ElemType int using namespace std; typedef int Status; typedef...原创 2020-03-18 14:55:54 · 1113 阅读 · 0 评论 -
8591 计算next值(kmp)
scau原题 #include "stdio.h" #include "stdlib.h" #define MAXSTRLEN 255 // 用户可在255以内定义最大串长 typedef unsigned char SString[MAXSTRLEN+1]; // 0号单元存放串的长度 void get_next(SString T,int next[]...原创 2020-03-04 19:32:22 · 1042 阅读 · 0 评论 -
8576 顺序线性表的基本操作(顺序表)
#include<stdio.h> #include<malloc.h> #define OK 1 #define ERROR 0 #define LIST_INIT_SIZE 100 #define LISTINCREMENT 10 #define ElemType int typedef struct { int *elem; int length; int l...原创 2020-03-04 16:09:58 · 1594 阅读 · 0 评论