
数据结构
森-Js
521
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
数组排序
题目描述输入一个数组的值,求出各个值从小到大排序后的次序。 输入输入有多组数据。 每组输入的第一个数为数组的长度n(1<=n<=10000),后面的数为数组中的值,以空格分割。 输出各输入的值按从小到大排列的次序(最后一个数字后面没有空格)。 样例输入168 151 70 25 79 59 63 65 6 46 82 28 62 92 96 43...原创 2018-08-06 09:13:35 · 348 阅读 · 0 评论 -
快速排序
#include<iostream>using namespace std;#define max 20int i,j,k,low,high,p,pk;typedef struct { int key; int otherwise;} type;typedef struct { //定义结构体 type a[max]; int length;} sqlist...原创 2019-01-01 20:29:51 · 124 阅读 · 0 评论 -
折半插入查找
#include<iostream>using namespace std;typedef struct{ int data; int otherwise;}elemtype;typedef struct{ elemtype a[20]; int length;}sstable;int search_bin(sstable s,int n){ int low=...原创 2018-12-30 20:49:03 · 268 阅读 · 0 评论 -
普利姆算法(prim)
#include <iostream>#include <string>using namespace std;typedef struct MGraph { string vexs[10];//顶点信息 int arcs[10][10];//邻接矩阵 int vexnum, arcnum;} MGraph;typedef struct Closedg...原创 2018-12-30 10:55:35 · 756 阅读 · 0 评论 -
中缀表达式转化为后缀表达式
一、后缀表达式求值后缀表达式也叫逆波兰表达式,其求值过程可以用到栈来辅助存储。假定待求值的后缀表达式为:6 5 2 3 + 8 * + 3 + *,则其求值过程如下:1)遍历表达式,遇到的数字首先放入栈中,此时栈如下所示:2)接着读到“+”,则弹出3和2,执行3+2,计算结果等于5,并将5压入到栈中。3)读到8,将其直接放入栈中。4)读到“*”,弹出8和5,执行8*...转载 2018-12-29 12:00:33 · 208 阅读 · 0 评论 -
邻接表的深度优先遍历
#include<iostream>using namespace std;#define max 100int i,j,m1,m2,n1,n2,w,visited[100];typedef struct ArcNode { //边结点 int adjvex; //该边所指向的顶点位置 struct ArcNode * nextarc;...原创 2018-12-24 09:14:30 · 6994 阅读 · 1 评论 -
循环队列的基本操作(顺序结构)
#include<iostream>#include<cstdlib> using namespace std;#define max 100#define overflow 0#define error -1#define ok 1typedef struct { int *base; int front; int rear;}sqQueue;...原创 2018-12-29 11:02:50 · 924 阅读 · 0 评论 -
出栈序列统计
题目描述栈是常用的一种数据结构,有n个元素在栈顶端一侧等待进栈,栈顶端另一侧是出栈序列。你已经知道栈的操作有两种:push和pop,前者是将一个元素进栈,后者是将栈顶元素弹出。现在要使用这两种操作,由一个操作序列可以得到一系列的输出序列。请你编程求出对于给定的n,计算并输出由操作数序列1,2,…,n,经过一系列操作可能得到的输出序列总数。输入一个整数n(1<=n<=15) ...原创 2018-11-08 17:10:42 · 297 阅读 · 0 评论 -
多项式相加减
单链表多项式的相加减#include<cstdio>#include<iostream>using namespace std;typedef struct pnode{ int a; //系数 int na; //指数 struct pnode *next; //指针域 }pno...原创 2018-10-23 21:17:12 · 934 阅读 · 0 评论 -
两集合的并集(线性表)
#include<cstdio>#include<iostream>#define max 100#define ok 1;using namespace std;typedef int elemtype;typedef int status;typedef struct { elemtype *elem; //记录相应元素的位置 int...原创 2018-10-17 10:41:42 · 1804 阅读 · 0 评论 -
简单计算器
读入一个只包含 +, -, *, / 的非负整数计算表达式,计算该表达式的值。 Input测试输入包含若干测试用例,每个测试用例占一行,每行不超过200个字符,整数和运算符之间用一个空格分隔。没有非法表达式。当一行中只有0时输入结束,相应的结果不要输出。 Output对每个测试用例输出1行,即该表达式的值,精确到小数点后2位。 Sample Input1 + 24 + ...原创 2018-09-09 21:10:30 · 222 阅读 · 0 评论 -
1140-鸡蛋栈
题目描述: 继队列之后,我们又来学习一种新的数据结构——栈。将队列的头部封闭后,就构成了栈这种数据结构,原来队列头部就是栈底,原来队列的尾部就是栈顶。栈与队列的不同就在于栈的底端是封闭的。所以,栈的插入和删除操作只能在栈的一端进行,即栈顶。栈的插入操作称为入栈,删除操作称为出栈。底________________顶|底—————————顶输入描述:第一行输入一个...原创 2019-03-12 20:17:49 · 154 阅读 · 0 评论