自定义博客皮肤VIP专享

*博客头图:

格式为PNG、JPG,宽度*高度大于1920*100像素,不超过2MB,主视觉建议放在右侧,请参照线上博客头图

请上传大于1920*100像素的图片!

博客底图:

图片格式为PNG、JPG,不超过1MB,可上下左右平铺至整个背景

栏目图:

图片格式为PNG、JPG,图片宽度*高度为300*38像素,不超过0.5MB

主标题颜色:

RGB颜色,例如:#AFAFAF

Hover:

RGB颜色,例如:#AFAFAF

副标题颜色:

RGB颜色,例如:#AFAFAF

自定义博客皮肤

-+
  • 博客(25)
  • 收藏
  • 关注

原创 普通树的非递归遍历

#include#include#include#define M 3#define MAX 300FILE*rf;void open(){ rf=fopen("tree.txt","r");}void off(){ fclose(rf);}void in(char *ch){ fscanf(rf,"%c",ch);}//以上为了输入方便,定义从文件

2015-04-29 19:49:14 1831

原创 6_43_递归交换二叉树中所有节点的左右子树

#include#include#includetypedef struct node{ int data; struct node*lchild,*rchild;}tnode,*tree;tree creat(){ int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else

2015-04-25 16:16:09 1439

原创 6_44_二叉树中值为x的节点为根的子树的深度

#include#include#includetypedef struct node{ int data; struct node*lchild,*rchild;}tnode,*tree;tree creat(){ int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else

2015-04-25 16:15:56 750

原创 6_42_二叉树递归求叶子节点个数

#include#include#includetypedef struct node{ int data; struct node*lchild,*rchild;}tnode,*tree;tree creat(){ int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else

2015-04-25 16:15:30 425

原创 6_39_二叉树增加两个域不用栈进行递推后序遍历树

#include#include#includetypedef struct node{ int data; int mark; struct node*lchild,*rchild,*parent;}tnode,*tree;tree creat(){ int x; tree t; scanf("%d",&x); if(x==0

2015-04-25 16:13:38 406

原创 6_41_递归求出二叉树先序遍历第k个节点的元素的值

#include#include#includetypedef struct node{ int data; struct node*lchild,*rchild;}tnode,*tree;tree creat(){ int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else

2015-04-25 16:13:13 2736

原创 6_38_二叉树的后序遍历非递归算法(和先序有些许不一样)

#include#include#includetypedef struct node{ int data,tag; struct node*lchild,*rchild;}tnode,*tree;tree creat(){ int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else

2015-04-25 16:13:06 396

原创 6_37_二叉树的先序遍历非递归算法

#include#include#includetypedef struct node{ int data; struct node*lchild,*rchild;}tnode,*tree;tree creat(){ int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else

2015-04-25 16:10:57 438

原创 6_36_相似二叉树

#include#include#includetypedef struct node{ int data; struct node*lchild,*rchild;}tnode,*tree;tree creat(){ int x; tree t; scanf("%d",&x); if(x==0)t=NULL; else

2015-04-25 16:10:05 412

原创 6_33_两个一维数组判断u是否为v的子孙

#includeint L[6+1]={0,2,4,0,6,0,0};int R[6+1]={0,3,5,0,0,0,6};int n=6;int IfSon(int u,int v){ if(u&&v){ if(L[v]==u||R[v]==u) return 1; else return(IfSon

2015-04-25 16:09:39 881

原创 6_34_扩展判断u是否为v的子孙

#includeint L[6+1]={0,2,4,0,6,0,0};int R[6+1]={0,3,5,0,0,0,0};int T[6+1];int n=6;void TransTo(){ int i; for(i=1;i<=n;i++) { T[L[i]]=i; T[R[i]]=i; } T[0]=0;}

2015-04-25 16:09:10 587

原创 HDOJ 4006 The kth great number

The kth great numberTime Limit : 2000/1000ms (Java/Other)   Memory Limit : 65768/65768K (Java/Other)Total Submission(s) : 4   Accepted Submission(s) : 3Font: Times New Roman | Verdana | Ge

2015-04-24 17:54:46 317

原创 HDOJ 1896 Stones

StonesTime Limit : 5000/3000ms (Java/Other)   Memory Limit : 65535/32768K (Java/Other)Total Submission(s) : 4   Accepted Submission(s) : 3Font: Times New Roman | Verdana | GeorgiaFont

2015-04-24 17:50:12 323

原创 HDOJ 1873 看病要排队

看病要排队Time Limit : 3000/1000ms (Java/Other)   Memory Limit : 32768/32768K (Java/Other)Total Submission(s) : 16   Accepted Submission(s) : 9Font: Times New Roman | Verdana | GeorgiaFont

2015-04-24 17:47:24 503

原创 HDOJ 1509 Windows Message Queue

Windows Message QueueTime Limit : 2000/1000ms (Java/Other)   Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 7   Accepted Submission(s) : 3Font: Times New Roman | Verdana | G

2015-04-24 17:44:42 310

原创 HDOJ1053 Entropy

EntropyTime Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 4593    Accepted Submission(s): 1886Problem DescriptionAn entropy encoder

2015-04-24 17:31:55 293

原创 POJ 3617 Best Cow Line

给定长度N的字符串S,要求构造一个长度为N的字符串T,起初T是一个空串,随后反复进行如下操作:1.从字符串S的首部删除一个字符添加到T的末尾。2.从字符串S的尾部删除一个字符添加到T的末尾。要求构造的字符串T的字典序最小。可以按照如下算法:按照字典序比较当前字符串S及将它翻转后的字符串S‘,如果S>S',则从S开头删除一个字符添加到T末尾。如果S#i

2015-04-21 14:33:59 667

原创 区间问题

有n项工作,每项分别在si开始,ti结束,对于每项工作一旦开始不能中途结束,参与的工作时间不能重叠,尽可能多的参加工作,求解最多项。应该在每次可以选择的工作中,选择出最早结束的那个工作进行。#include#include#define MAX 500using namespace std;int S[MAX];//开始时间int T[MAX];//结束时间pair

2015-04-18 15:45:32 391

原创 选取硬币问题

有1元,5元,10元,50元,100元,500元的硬币各c0,c1,c2,c3,c4, c5枚现在要使用这些硬币支付n元,问最少需要多少枚硬币,假设至少存在一种方案。应该尽可能使用500元的,然后再使用100元的.....使用贪心策略。#include "stdafx.h"#include#includeusing namespace std;const int

2015-04-18 15:22:18 503

原创 Lake Counting

#include "stdafx.h"#include#define MAX 500using namespace std;char imap[MAX][MAX];int n, m;void dfs(int x, int y){ imap[x][y] = '.'; for (int dx = -1; dx <= 1; dx++) for (int dy = -1; dy <=

2015-04-18 14:00:05 318

原创 部分和问题

#include "stdafx.h"#include#define MAX 100using namespace std;int n=7, k;int num[100] = { 1, 3, 4, 2, 5, 6, 7 };bool dfs(int i, int sum){ if (i == n)return sum == k; if (dfs(i + 1, sum))retur

2015-04-18 13:58:41 284

原创 迷宫最短路

#include#include#include#include#define MAX 100using namespace std;const int INF = 10;typedef pairP;int d[MAX][MAX];char imap[MAX][MAX];int n, m;int sx, sy;int gx, gy;int To[4][2] = { {

2015-04-18 13:56:04 632

转载 sublime 的使用技巧

技巧一:快速注释 选择需要注释的代码,多行或单行都很随意,然后使用”Ctrl+/”,或者使用“Ctrl+Shft+/”即可快速注释。注释了再同样按一下即可接触注释。这里的注释比eclipse中的java好用。技巧二:快速查找 按住”Ctrl+F”快捷键,即可进行快速搜索,在搜索框下边输入要找的变量名称和方法名等都可以,定位很迅速。技巧三:缩略图定位 我们可以发现右侧可以看到整个代码的

2015-04-15 18:30:39 497

转载 解决 Git For Windows 无法提交

原文 http://mawenjian.net/p/1157.html最近因为需要使用Git管理代码,所以向来对Git不甚感冒的我,也不得不学习使用Git了。要用Git管理代码,Git客户端自然必不可少,可上网一搜,Windows下的Git客户端软件还真不多——Github for Windows,TortoiseGit和SmartGit。鉴于Github for Wind

2015-04-15 12:33:59 1295

原创 数组

#include#include#includeusing std::cin;using std::cout;typedef int type;typedef struct array{ type *base;//基址 int index[3];//数组每维大小 int count[3];//用于计算,储存每维的元素个数,例:每面,每行,每列的元素个数};//初始化三维

2015-04-14 20:34:35 301

空空如也

空空如也

TA创建的收藏夹 TA关注的收藏夹

TA关注的人

提示
确定要删除当前文章?
取消 删除