
数据结构
文章平均质量分 72
小銍
这个作者很懒,什么都没留下…
展开
-
SDUT 3340 数据结构实验之二叉树一:树的同构
点击打开题目链接原创 2016-08-01 11:28:04 · 789 阅读 · 1 评论 -
SDUT 3361 数据结构实验之图论四:迷宫探索
点击打开题目链接#include using namespace std;int n, m;bool Graph[1010][1010];int pp[1010], t;bool vis[1010];void DFS(int s);int main(){ int k, s; cin >> k; while(k --) { m原创 2016-07-29 19:56:45 · 526 阅读 · 2 评论 -
SDUT 2142 数据结构实验之图论二:基于邻接表的广度优先搜索遍历
点击打开题目链接#include using namespace std;struct node{ int data; node *next;};node *head[1010], *p;void BFS(int s);bool vis[1010];int n, m, s;int main(){ int k; cin >> k;原创 2016-07-28 09:04:30 · 1791 阅读 · 0 评论 -
SDUT 3343 数据结构实验之二叉树四:还原二叉树
点击打开题目链接#include using namespace std;struct node{ char data; node *right, *left;};int lenth;char str1[60], str2[60];node *creat();int high(node *root);//二叉树高度node *build(int low,原创 2016-07-22 17:00:50 · 303 阅读 · 0 评论 -
SDUT 2804 求二叉树的深度
点击打开题目链接#include using namespace std;struct node{ char data; node *right, *left;};int len, k;char str1[60], str2[60], str3[60];node *creat();int high(node *root);//二叉树高度node *bu原创 2016-08-09 11:55:46 · 256 阅读 · 0 评论 -
SDUT 2127 树-堆结构练习——合并果子之哈夫曼树
点击打开题目链接优先队列:原文链接优先队列:顾名思义,首先它是一个队列,但是它强调了“优先”二字,所以,已经不能算是一般意义上的队列了,它的“优先”意指取队首元素时,有一定的选择性,即根据元素的属性选择某一项值最优的出队~百度百科上这样描述的: 优先级队列 是不同于先进先出队列的另一种队列。每次从队列中取出的是具有最高优先权的元素 优先队列的类定义 优先队列是0个原创 2016-08-01 21:04:31 · 862 阅读 · 0 评论 -
SDUT 2140 图结构练习——判断给定图是否存在合法拓扑序列
点击打开题目链接判断是否存在环,每一次找到入度为0的点,将其相关联的点的入度--,如果还存在入度不为0的点,则原图一定存在环#include using namespace std;bool Graph[15][15];int Indu[15];bool vis[15];int main(){ int n, m; while(cin >> n >> m)原创 2016-08-04 20:14:46 · 366 阅读 · 0 评论 -
HDU 1232 畅通工程
点击打开题目链接#include using namespace std;int pre[1010];int Find(int x);int join(int x, int y);int main(){ int n, m; while(cin >> n, n) { for(int i = 1; i <= n; i++) {原创 2016-08-11 15:13:35 · 252 阅读 · 0 评论 -
SDUT 1488 数据结构实验:连通分量个数
点击打开题目链接#include using namespace std;int pre[1010];int Find(int x);int join(int x, int y);int main(){ int n, m, k; cin >> k; while(k --) { cin >> n >> m; for原创 2016-08-11 15:22:03 · 406 阅读 · 0 评论 -
SDUT 3467 图的基本存储的基本方式四
点击打开题目链接duang duang duang,题意看错,一直交,一直wa, 悲哀!#include #include using namespace std;struct node{ int data; node *next;};node *head[5020];void creat(int n){ for(int i = 0; i <原创 2016-08-07 17:13:53 · 581 阅读 · 0 评论 -
SDUT 3377 数据结构实验之查找五:平方之哈希表
点击打开题目链接#include using namespace std;int Hash[1010];int n, m;int main(){ while(~scanf("%d %d", &n, &m)) { queueQ; memset(Hash, 0, sizeof(Hash)); for(int i = 1;原创 2016-08-07 15:59:55 · 628 阅读 · 0 评论 -
SDUT 3345 数据结构实验之二叉树六:哈夫曼编码
点击打开题目链接就是不明白给啥gets就是不对,后台读数据又问题,嗯,一定是#include using namespace std;int pp[140];char str[140];int main(){ while(~scanf("%s",str)) { getchar(); memset(pp, 0, sizeof(原创 2016-08-04 20:58:37 · 1035 阅读 · 0 评论 -
SDUT 3341数据结构实验之二叉树二:遍历二叉树
点击打开题目链接#include using namespace std;struct node{ char data; node *right, *left;};int i;char str[60];node *creat();//void preorder(node *root);前序遍历void Inorder(node *root);//中序遍历原创 2016-07-22 11:08:50 · 514 阅读 · 0 评论 -
SDUT 3402 数据结构实验之排序五:归并求逆序数
点击打开题目链接坑坑坑,超时,过,傻傻分不清#include using namespace std;int n;long long num;int pp[100010], tmp[100010];void Msort(int l, int r);void Merge( int l, int e,int m, int r);int main(){ num = 0原创 2016-08-05 21:33:56 · 369 阅读 · 0 评论 -
SDUT 3403 数据结构实验之排序六:希尔排序
点击打开题目链接#include using namespace std;int pp[10010];int main(){ int n; while(cin >> n) { int i; for( i = 0; i < n; i++) { scanf("%d", &pp[i]);原创 2016-08-06 09:59:20 · 385 阅读 · 0 评论 -
SDUT 3400 数据结构实验之排序三:bucket sort
点击打开题目链接感觉就好像哈希存了一下,悲哀#include using namespace std;int bucket[120];int main(){ int n; memset(bucket, 0, sizeof(bucket)); cin >> n; for(int i = 0; i < n; i++) {原创 2016-08-06 10:34:51 · 457 阅读 · 0 评论 -
前缀、中缀、后缀表达式
关键字:概念, 前缀表达式, 前缀记法, 中缀表达式, 中缀记法, 波兰式, 后缀表达式, 后缀记法, 逆波兰式它们都是对表达式的记法,因此也被称为前缀记法、中缀记法和后缀记法。它们之间的区别在于运算符相对与操作数的位置不同:前缀表达式的运算符位于与其相关的操作数之前;中缀和后缀同理。举例:(3 + 4) × 5 - 6 就是中缀表达式- × + 3 4 5 6 前缀表转载 2016-07-31 19:56:04 · 337 阅读 · 0 评论 -
SDUT 3364 数据结构实验之图论八:欧拉回路
点击打开题目链接#include using namespace std;bool Graph[1010][1010];bool vis[1010];int du[1010];int sum, n, k, m;;void DFS(int s);int main(){ cin >> k; while(k --) { sum = 0;原创 2016-08-03 09:11:41 · 702 阅读 · 0 评论 -
SDUT 3404 数据结构实验之排序七:选课名单
点击打开题目链接#include using namespace std;struct node{ char name[15];} pp[2010][35002];int Hash[2010];//统计当前课程选课情况int cmp(node a, node b){ return strcmp(a.name,b.name) < 0;}int main()原创 2016-08-06 14:56:32 · 804 阅读 · 0 评论 -
SDUT 3379 数据结构实验之查找七:线性之哈希表
点击打开题目链接#include using namespace std;int Hash[1010];int n, m;int main(){ while(~scanf("%d %d", &n, &m)) { queueQ; memset(Hash, 0, sizeof(Hash)); for(int i = 1;原创 2016-08-06 19:34:08 · 831 阅读 · 2 评论 -
SDUT 2805 大家快来A水题
点击打开题目链接#include using namespace std;int pre[2010];int Find(int x);int join(int x, int y);int main(){ int n, m; while(cin >> n >> m) { for(int i = 1; i <= n; i++)原创 2016-08-11 15:27:57 · 383 阅读 · 0 评论 -
SDUT 2129 树结构练习——判断给定森林中有多少棵树
点击打开题目链接#include using namespace std;bool Graph[100][100];bool vis[100];void DFS(int s);int n, m;int num;int main(){ while(cin >> n >> m) { num = 0; int flag = 1; memset(vis,原创 2016-08-05 11:46:52 · 338 阅读 · 0 评论 -
SDUT 3347 数据结构实验之数组三:快速转置
#include #define Max 100#define OK 1using namespace std;typedef int Elemtype;typedef int Status;typedef struct{ int i, j; Elemtype e;}Triple;typedef struct{ Triple data[Max+1]原创 2016-11-01 17:00:58 · 478 阅读 · 0 评论 -
SDUT 3374 数据结构实验之查找二:平衡二叉树
点击打开题目链接#include using namespace std;struct Treenode{ int data; int height; Treenode *leftchild, *rightchild;};int GetHeight(Treenode *p);//树高void Preorder(Treenode *p);//前序遍历Tr原创 2016-08-08 17:38:31 · 494 阅读 · 0 评论 -
SDUT 3401 数据结构实验之排序四:寻找大富翁
点击打开题目链接感觉再也不敢用#include了, 交了好多发MLE#include int n, m;int data[12];//建立最小堆void HeapAdjust(int data[], int s, int len){ int x = data[s]; for(int j = 2*s; j <= len; j*=2) { if(原创 2016-08-04 15:22:52 · 1689 阅读 · 1 评论 -
SDUT 3362 村村通公路
点击打开链接#include #include #include #define INF 0x3f3f3f3fusing namespace std;int mp[3010][3010];bool vis[3010];int dis[3010];void Prim();int n, m;int main(){ int u, v, w; while(~s原创 2016-07-04 10:13:09 · 382 阅读 · 0 评论 -
SDUT 3363 数据结构实验之图论七:驴友计划
点击打开题目链接//数据结构实验之图论七:驴友计划#include #define INF 0x3f3f3f3fusing namespace std;struct node{ int l; int v;} mp[1010][1010];int main(){ int k; cin >> k; while(k --) {原创 2016-07-27 09:48:38 · 650 阅读 · 0 评论 -
SDUT 2498 AOE网上的关键路径
点击打开题目链接表示交了好多WA,逆序建图,逆序建图,逆序建图,说了三遍,目测应该够了,悲哀啊,顺序建就是不好存路径,悲哀啊!!!!#include #define INF 0x3f3f3f3f#define N 10010using namespace std;struct Arcnode{ int to; int weight; Arcnode原创 2016-08-15 10:21:38 · 526 阅读 · 0 评论 -
SDUT 3375 数据结构实验之查找三:树的种类统计
点击打开题目链接#include using namespace std;struct node{ char str[25]; int sum; node *left, *right;};int n;node *Insert(node *root, char *st);//void Insert(node *(&root), char *st);ins原创 2016-08-03 14:55:43 · 308 阅读 · 0 评论 -
小C语言--词法分析程序
小C语言文法 1. →(){}2. →||3. →;4. →,|5. →|6. →||||7. →()|()8. →()9. →(;;)10. →{}11. →;12. →=|13. → |14. →>|=|15. →+|-|16. →*|/|17. →||()18. →||19. →|20. →a|b|…|z|A原创 2017-11-28 09:59:07 · 466 阅读 · 0 评论 -
SDUT 3348 数据结构实验之数组二:稀疏矩阵
点击打开题目链接#include using namespace std;struct node{ int l, r, v;} pp[1010];int main(){ int mu, nu, tu; while(cin >> mu >> nu >> tu) { int flag = 0; for(int i =原创 2016-07-29 20:32:49 · 446 阅读 · 0 评论 -
SDUT 2107 图的深度遍历
点击打开题目链接#include using namespace std;bool vis[100];int n, k, m, s, u, v;int Graph[100][100];void DFS(int s);int main(){ cin >> k; while(k --) { memset(Graph, 0, sizeof(G原创 2016-07-24 11:51:08 · 770 阅读 · 0 评论 -
顺序表应用4-2:元素位置互换之逆置算法(数据改进)
#include #include #include using namespace std;#define LISTINCREASMENT 100#define LISTSIZE 1000001#define OVERLFLOW -1#define OK 1typedef int ElemType;typedef struct{原创 2016-09-22 09:33:53 · 1343 阅读 · 0 评论 -
SUDT 2144 图结构练习——最小生成树
点击打开题目链接#include #define INF 0x3f3f3f3fusing namespace std;int Graph[10010][10010];bool vis[10010];int dis[10010];void Prim();int n, m;int main(){ while(cin >> n >> m) {原创 2016-08-05 15:25:42 · 320 阅读 · 0 评论 -
SDUT 3468 广度优先搜索练习之神奇的电梯
点击打开题目链接#include using namespace std;struct edge{ int num; int step;};int n, m, q, pos;bool Edge[210][210];bool vis[210];int BFS(int st, int pos);int main(){ while(cin >>原创 2016-08-11 21:16:14 · 675 阅读 · 0 评论 -
HDU 1285 确定比赛名次
点击打开题目链接//暴力#include using namespace std;int Edge[510][510];int Indegree[510];int vis[510];int main(){ int n, m; while(cin >> n >> m) { memset(Edge, 0, sizeof(Edge));原创 2016-08-12 11:22:27 · 301 阅读 · 0 评论 -
SDUT 3334 数据结构实验之栈七:出栈序列判定
点击打开题目链接#include using namespace std;int a[10010], b[10010];//原序列,新序列int main(){ int n, k; cin >> n; for(int i = 0; i < n; i++) { scanf("%d", &a[i]); } cin >>原创 2016-07-20 15:43:19 · 1408 阅读 · 1 评论 -
SDUT 2137 数据结构实验之求二叉树后序遍历和层次遍历
点击打开题目链接#include using namespace std;struct node{ char data; node *right, *left;};int lenth;char str1[60], str2[60];node *creat();void Postorder(node *root);//后序遍历void levelorder(原创 2016-07-22 16:30:10 · 367 阅读 · 0 评论 -
SDUT 2143 图结构练习——最短路径
#include #include #define INF 0x3f3f3f3fusing namespace std;int mp[10010][10010];int main(){ int n, m, a, b, c; while(cin >> n >> m, n&&m) { for(int i = 1; i<=n; i++)原创 2016-06-09 13:29:09 · 560 阅读 · 1 评论 -
顺序表应用3:元素位置互换之移位算法
#include using namespace std;#define LISTINCREASMENT 100#define LISTSIZE 10010#define OVERLFLOW -1#define OK 1typedef int ElemType;typedef struct{ ElemType *elem; int length;原创 2016-09-19 19:36:25 · 472 阅读 · 0 评论