10 2016 档案
判断二叉树是否相等
摘要:#include<cstdio>#include<iostream>#include<algorithm>using namespace std; typedef struct node{ int data; struct node *lc; struct node *rc; }BiNode,*Bi 阅读全文
posted @ 2016-10-30 19:41 Dove1 阅读(282) 评论(0) 推荐(0)
统计二叉树叶子节点的数目
摘要:int LeafCount(BiTree T){ if(T==NULL) return 0; if(T->lchild==NULL&&T->rchild==NULL) return 1; else return LeafCount(T->lchild)+LeafCound(T->rchild);} 阅读全文
posted @ 2016-10-29 21:53 Dove1 阅读(450) 评论(0) 推荐(0)
交换二叉树的左右孩子
摘要:typedef char TElemType; typedef struct BiNode{ TElemType data; stuct BiNode *lchild,*rchild;}BiNode,*BiTree; tree create(){ int x; tree t; scanf("%d", 阅读全文
posted @ 2016-10-29 21:53 Dove1 阅读(396) 评论(0) 推荐(0)
根据先序,中序,求后序遍历#include<cstdio> #include<cstring> #include<iostream> using namespace std; struct Node { char data; Node *lchild,*rchild; }; Node* createtree(string pre,string in) { Node *root=NULL
摘要:#include<cstdio>#include<cstring>#include<iostream>using namespace std; struct Node{ char data; Node *lchild,*rchild;}; Node* createtree(string pre,st 阅读全文
posted @ 2016-10-29 21:52 Dove1 阅读(825) 评论(0) 推荐(0)
判断先,中,后,层次遍历序列相同的代码
摘要:#include<stdio.h>#include<stdlib.h>#include<malloc.h>#include<string.h> char s1[1000],s2[1000],s3[1000],s4[1000]; typedef struct node{ char data; stru 阅读全文
posted @ 2016-10-29 21:50 Dove1 阅读(365) 评论(0) 推荐(0)
二叉树的二叉链存储结构及表示
摘要:实验目的:掌握二叉树的二叉链存储结构及表示。 掌握二叉树的三种遍历算法(递归和非递归两类)。 运用三种遍历的方法求解二叉树的有关问题。 实验内容:实现二叉树的二叉链表存储结构; 实现先序、中序和后序遍历二叉树; 遍历二叉树的应用:计算叶子结点、左右子树交换等。 要求:1、二叉树基本操作已实现,学习和 阅读全文
posted @ 2016-10-29 21:48 Dove1 阅读(1018) 评论(0) 推荐(0)
poj Charm BraceletBessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ N ≤ 3,402) available charms. E
摘要:Bessie has gone to the mall's jewelry store and spies a charm bracelet. Of course, she'd like to fill it with the best charms possible from the N (1 ≤ 阅读全文
posted @ 2016-10-27 22:10 Dove1 阅读(701) 评论(0) 推荐(0)
Good Luck in CET-4 Everybody!(博弈)
摘要:大学英语四级考试就要来临了,你是不是在紧张的复习?也许紧张得连短学期的ACM都没工夫练习了,反正我知道的Kiki和Cici都是如此。当然,作为在考场浸润了十几载的当代大学生,Kiki和Cici更懂得考前的放松,所谓“张弛有道”就是这个意思。这不,Kiki和Cici在每天晚上休息之前都要玩一会儿扑克牌 阅读全文
posted @ 2016-10-27 08:46 Dove1 阅读(210) 评论(0) 推荐(0)
poj An easy problem
摘要:Imagine you are attending your math lesson at school. Once again, you are bored because your teacher tells things that you already mastered years ago 阅读全文
posted @ 2016-10-26 22:26 Dove1 阅读(233) 评论(0) 推荐(0)
cin和cout的用法(头文件是<iostream>)
摘要:一:标准输入函数cin 它是代表标准的输入设备--键盘,它是属于流的,他的用法和流的用法是一样的。也就是:cin>>变量; 输入多个变量可以写在一行,如:cin>>x>>y>>z; 这样写不好看,一般在输入语句的前面,都要做一个提示,”请输入×××”。 另外,这个函数是不用带地址符号"&"的,也不用 阅读全文
posted @ 2016-10-25 17:50 Dove1 阅读(6247) 评论(0) 推荐(0)
已知二叉树的先序遍历序列和中序遍历序列,求后序遍历序列。
摘要:思路: 先序序列的第一个结点为要构造二叉树的根结点,在中序序列中查找二叉树的根结点,则中序列根结点左边为根结点的左子树的中序序列,右边为根结点的右子树的中序序列。而先序序列根结点后面分别为它的左子树和右子树的先序序列。有了根结点在中序序列的位置,就知道了左子树和右子树的先序序列各自的位置。这样,就知 阅读全文
posted @ 2016-10-25 08:56 Dove1 阅读(799) 评论(0) 推荐(0)
二叉树的层次遍历
摘要:设计一个算法层序遍历二叉树(同一层从左到右访问)。思想:用一个队列保存被访问的当前节点的左右孩子以实现层序遍历。void HierarchyBiTree(BiTree Root){LinkQueue *Q; // 保存当前节点的左右孩子的队列InitQueue(Q); // 初始化队列if (Roo 阅读全文
posted @ 2016-10-24 19:25 Dove1 阅读(334) 评论(0) 推荐(0)
二叉树的先序,中序,后序递归遍历,以及计算节点的数目
摘要:方法一: //用先序,中序,后序的方法递归遍历二叉树 #include<stdio.h>#include<stdlib.h>#include<malloc.h> typedef int ElemType; typedef struct node{ ElemType data; struct node 阅读全文
posted @ 2016-10-23 20:25 Dove1 阅读(3089) 评论(0) 推荐(0)
结构体中typedef语句用法总结
摘要:结构体中typedef语句用法总结 typedef为C语言的关键字,作用是为一种数据类型(这里仅讨论结构体数据类型)定义一个新名字。在编程中使用typedef目的一般有两个:给变量一个易记且意义明确的新名字;简化一些比较复杂的类型声明。1、typedef的最简单使用 typedef int Data 阅读全文
posted @ 2016-10-23 09:46 Dove1 阅读(2218) 评论(0) 推荐(0)
An easy problem
摘要:One day Teddy met a old man in his dream , in that dream the man whose name was“RuLai” gave Teddy a problem : Given an N , can you calculate how many 阅读全文
posted @ 2016-10-09 21:59 Dove1 阅读(240) 评论(0) 推荐(0)