数据结构
wz_e18
这个作者很懒,什么都没留下…
展开
-
链表C语言简单实现
使用C语言完成的链表,分成linkQueue.h,和linkQueue.c两个文件原创 2019-01-07 22:30:57 · 126 阅读 · 0 评论 -
树的先序 中序 后序 非递归算法
非递归算法将空间消耗从栈区转换到堆区,避免了栈溢出的导致程序崩溃。 typedef struct trnode { char x; struct trnode* lchild, * rchild; } Trnode, *Tree; Tree buildtree(char * &s) { if(*s && *s != ',') { ...原创 2019-01-19 23:42:13 · 160 阅读 · 0 评论 -
SDUTOJ - 2131 数据结构实验之栈与队列一:进制转换
题目链接 #include <iostream> #include <cstdlib> using namespace std; typedef int ElementType; typedef struct Snode { ElementType x; struct Snode * next; } Snode, *Ptr_snode; typ...原创 2018-10-10 10:33:52 · 301 阅读 · 0 评论 -
POJ-1062 昂贵的聘礼
年轻的探险家来到了一个印第安部落里。在那里他和酋长的女儿相爱了,于是便向酋长去求亲。酋长要他用10000个金币作为聘礼才答应把女儿嫁给他。探险家拿不出这么多金币,便请求酋长降低要求。酋长说:"嗯,如果你能够替我弄到大祭司的皮袄,我可以只要8000金币。如果你能够弄来他的水晶球,那么只要5000金币就行了。"探险家就跑到大祭司那里,向他要求皮袄或水晶球,大祭司要他用金币来换,或者替他弄来其他的东西,...原创 2018-10-10 09:24:18 · 117 阅读 · 0 评论 -
SDUTOJ-2054 数据结构实验之链表九:双向链表
题目链接 #include <iostream> #include <cstdlib> using namespace std; typedef int ElementType; typedef struct node { ElementType x; struct node * next; struct node * front; } ...原创 2018-10-10 09:18:42 · 226 阅读 · 0 评论 -
SDUTOJ-3331 数据结构实验之链表八:Farey序列
链表节点插入练习题 题目链接 #include <stdio.h> #include <cstdlib> using namespace std; typedef int ElementType; typedef struct node { ElementType x, y; struct node * next; } Lnode; typede...原创 2018-10-08 17:02:07 · 132 阅读 · 0 评论 -
类实现 链表
刚接触面相对象,自己猜着写的,请多指教 #include <stdio.h> #include <stdlib.h> #include <string.h> template <class ElementType> class List { private : typedef struct Lnode { Ele...原创 2018-09-27 21:57:01 · 733 阅读 · 0 评论 -
CSU - 1960 - 单源最大权路径
题目链接:1960: 单源最大权路径 Description 有一棵由N个结点构成的树,每一条边上都有其对应的权值。现在给定起点,求从该点出发的一条路径(至少有一条边)使得这条路径上的权值之和最大,并输出这个最大值。 Input 第一行一个正整数T,代表数据组数。每组数据第一行两个正整数n(2<=n<=10^5),s(1<=s<=n),分别表示树结点数目以及给定的起...翻译 2018-09-06 08:54:42 · 116 阅读 · 0 评论 -
SDUT 3330 二分查找
顺序表的应用 题目链接 #include <cstdio> #include <cstdlib> const int Maxsize = 1e6+5; typedef int ElemType; typedef struct { ElemType *ele; int length; int maxsize; } List; int Bina...原创 2018-09-26 08:50:39 · 202 阅读 · 0 评论 -
SDUT 3363 元素位置互换之逆置算法
#include <cstdio> #include <cstdlib> const int Maxsize = 1e6+5; typedef int ElemType; typedef struct { ElemType *ele; int length; int maxsize; } List; void Swap(int &p,...翻译 2018-09-05 23:16:27 · 148 阅读 · 0 评论 -
阶乘 C
一个求 1——n 中所有数阶乘的程序 #include <stdio.h> int a[100000];//数组大点安全 int main() { int i, dig = 1, jin = 0, n; a[0] = 1; scanf("%d", &n); for(int i = 1; i <= n; i++) { ...原创 2018-09-05 17:14:18 · 229 阅读 · 0 评论