数据结构
文章平均质量分 80
查尔德77
努力改变自己
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
一道OJ,栈的简易应用。Matrix Chain Multiplication
原题地址 http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=94#include #include #include using namespace std;class matrixC{ public: char name; int row,col; ma原创 2014-05-21 15:08:35 · 693 阅读 · 0 评论 -
链表水题一道sicily 1934.移动小球 -- 线性结构,链表,水题
题目描述你有一些小球,从左到右依次编号为1,2,3,...,n. 你可以执行两种指令(1或者2)。其中, 1 X Y表示把小球X移动到小球Y的左边, 2 X Y表示把小球X移动到小球Y右边。 指令保证合法,即X不等于Y。 例如,初始状态1,2,3,4,5,6的小球执行1 1 4后,小球1被移动到小球4的左边,即2,3,1,4,5,6。如果再执行2 3 5,结点3将会移到5的右边,即2,1,原创 2014-07-06 18:16:39 · 870 阅读 · 0 评论 -
猴子选王-链表水题
#include#include using namespace std;struct NodeT{ int n; NodeT *next,*front;};NodeT* kill(NodeT *p,int Kn){ //从给你的指针位置开始数1 ,一直数到 Kn //把那个人杀掉,并且返回被杀掉的后一个人的指针。 NodeT *pre=p;原创 2014-07-07 17:27:50 · 893 阅读 · 0 评论 -
重建二叉树
题目描述:输入某二叉树的前序遍历和中序遍历的结果,请重建出该二叉树。假设输入的前序遍历和中序遍历的结果中都不含重复的数字。例如输入前序遍历序列{1,2,4,7,3,5,6,8}和中序遍历序列{4,7,2,1,5,3,8,6},则重建二叉树并输出它的后序遍历序列。输入:输入可能包含多个测试样例,对于每个测试案例,输入的第一行为一个整数n(1输入的第二行包括n个整数(其原创 2014-07-08 14:45:42 · 540 阅读 · 0 评论 -
POJ-模拟-1208 The Blocks Problem
The Blocks ProblemTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 4400 Accepted: 1822DescriptionMany areas of Computer Science use simple, abstract doma原创 2014-07-09 23:14:10 · 580 阅读 · 0 评论 -
UVA-133 双向链表模拟题
The Dole Queue In a serious attempt to downsize (reduce) the dole queue, The New National Green Labour Rhinoceros Party has decided on the following strategy. Every day all dole applicants原创 2014-07-10 20:31:29 · 512 阅读 · 0 评论 -
poj 1539 Evaluating Simple C Expressions
虽然划分在数据结构里,但感觉什么都没用到。简单的字符串处理罢了。原创 2014-07-30 11:53:09 · 471 阅读 · 0 评论 -
UVA 括号匹配
Parentheses Balance You are given a string consisting of parentheses () and []. A string of this type is said to be correct:(a)if it is the empty string(b)if A and B are correct, AB is c原创 2014-07-13 21:46:47 · 503 阅读 · 0 评论 -
uva 705 Slash Maze
用#include #include #include #include #include #include #include using namespace std;int height,width,cnt;int map[240][240];int ans,times=0;int step_x[]={1,-1,0,0};int step_y[]={0,0,1,-1};原创 2014-08-03 11:08:39 · 523 阅读 · 0 评论 -
中缀转前缀
#include #include #include using namespace std;struct num_strT{ //0代表数字 1 代表字符 bool flag; int num; char str;};class stack1{ public: char wait[1005]; int count;原创 2014-07-04 13:14:49 · 827 阅读 · 0 评论 -
ACM之广搜
广度优先搜索,超级好玩,原创 2014-05-28 20:32:06 · 735 阅读 · 0 评论 -
UVA 297 四叉树合并 Quadtrees
用一个Dps,把它输出来。A quadtree is a representation format used to encode images. The fundamental idea behind the quadtree is that any image can be split into four quadrants. Each quadrant may again be spli原创 2014-07-21 09:36:52 · 1021 阅读 · 0 评论 -
栈的简易应用,愚人节的礼物
#include #include #include using namespace std;int main(){ stack myStack; char s[1002],*p,temp; int j,n; while(cin>>s){ n=strlen(s); for(j=0;j { i原创 2014-05-21 13:53:55 · 580 阅读 · 0 评论 -
Generalized Matrioshkas. poj 栈 POJ3195
Generalized MatrioshkasTime Limit: 1000MS Memory Limit: 65536KTotal Submissions: 1816 Accepted: 528DescriptionVladimir worked for years making matrioshkas, thos原创 2014-07-15 20:55:34 · 664 阅读 · 0 评论 -
UVa 11234 Expressions
一道树的题目#include #include#include#include#include#include#include#include#include#include#includeusing namespace std;struct node{ char data; node*left; node*right;};node*原创 2014-07-16 14:12:49 · 434 阅读 · 0 评论 -
poj 1145 tree summing
Tree SummingTime Limit: 1000MS Memory Limit: 10000KTotal Submissions: 7866 Accepted: 1815DescriptionLISP was one of the earliest high-level programming languages原创 2014-07-17 09:51:00 · 543 阅读 · 0 评论 -
UVA 540 team queue
Team Queue Queues and Priority Queues are data structures which are known to most computer scientists. The Team Queue, however, is not so well known, though it occurs often in everyday lif原创 2014-07-16 16:18:59 · 1419 阅读 · 0 评论 -
队列简易应用
Problem Description某部队进行新兵队列训练,将新兵从一开始按顺序依次编号,并排成一行横队,训练的规则如下:从头开始一至二报数,凡报到二的出列,剩下的向小序号方向靠拢,再从头开始进行一至三报数,凡报到三的出列,剩下的向小序号方向靠拢,继续从头开始进行一至二报数。。。,以后从头开始轮流进行一至二报数、一至三报数直到剩下的人数不超过三人为止。原创 2014-05-23 22:20:20 · 590 阅读 · 0 评论 -
HDU--1253---胜利大逃亡 广度优先搜索
胜利大逃亡Time Limit: 4000/2000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 21542 Accepted Submission(s): 8479Problem DescriptionIgnatius被魔王抓走了,原创 2014-06-28 10:07:28 · 383 阅读 · 0 评论 -
树的重建与遍历
重建一棵树 Tree You are to determine the value of the leaf node in a given binary tree that is the terminal node of a path of least value from the root of the binary tree to any le原创 2014-07-20 21:20:28 · 772 阅读 · 0 评论 -
uva 110
#include #include #include #include #include using namespace std;vectorv;int total;vector::iterator itr;char alph[10]={'#','a','b','c','d','e','f','g','h'};void dps(int n){ // 这里添加进来的是 元原创 2014-08-21 10:21:07 · 438 阅读 · 0 评论
分享