二叉树的存储结构
typedef struct tnode
{
elemtype data;
struct tnode *lchild;
struct tnode *rchild;
}*bitree,bitnode;
二叉树的创建(按照先序遍历来创建)
Continue reading
这是博主关于C,C++的总结及经验.一切从hello world!开始 : )
二叉树的存储结构
typedef struct tnode
{
elemtype data;
struct tnode *lchild;
struct tnode *rchild;
}*bitree,bitnode;
二叉树的创建(按照先序遍历来创建)
Continue reading
1.要在函数中使用参数,首先要包含头文件。
C++中使用头文件 #include
这个头文件声明了一个va_list类型,定义了四个宏,用来遍历可变参数列表。
va在这里是variable-argument(可变参数)的意思.
void va_start(va_list ap, last);
type va_arg(va_list ap, type);
void va_end(va_list ap);
void va_copy(va_list dest, va_list src);
下面详细介绍这些宏定义: Continue reading
初学数据结构,实现了串的基本操作,记录如下
StrAssign(HString &T,char *chars)
//生成一个其值等于串常量的chars的串T
StrInsert(HString &S,int pos,HString T)
//在串S的第pos个字符之前插入串T
Display(HString S)
//输出,显示串
StrCompare(HString S,HString T)
//按照字典序比较HString的大小,越排后越大
//若S>T,则返回值>0;若S=T,则返回值=0;若S
学习数据结构必不可少的问题:
typedef是类型定义的意思。typedef struct 是为了使用这个结构体方便。
具体区别在于:
若struct node {}这样来定义结构体的话。在申请node 的变量时,需要这样写,struct node n;
若用typedef,可以这样写,typedef struct node{}NODE; 。在申请变量时就可以这样写,NODE n;
区别就在于使用时,是否可以省去struct这个关键字。
Continue reading
Tian Ji — The Horse Racing
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 9786 Accepted Submission(s): 2718
Description
Here is a famous story in Chinese history. Continue reading
求用1分、2分、3分的邮票贴出不同数值的方案数:
G(x)=(1+x+x2+x3…..)(1+x2+x4+x6…….)(1+x3+x6+x9……..)
以展开后的x4为例,其系数为4,即4拆分成1、2、3之和的拆分数为4;
即 :4=1+1+1+1=1+1+2=1+3=2+2
代码: Continue reading
这道题据说是动态规划的入门题目,不过对于初学者来说,还是不可小觑的 😛 just like me
Problem Description
A subsequence of a given sequence is the given sequence with some elements (possible none) left out. Given a sequence X =
The program input is from a text file. Each data set in the file contains two strings representing the given sequences. The sequences are separated by any number of white spaces. The input data are correct. For each set of data the program prints on the standard output the length of the maximum-length common subsequence from the beginning of a separate line.
—————————————————————————————————————————————— Continue reading
有一颗二叉树,最大深度为D,所有叶子的深度都相同。所有结点从上到下从左到右的编号分别依次是1,2,3,4,~,(2的D次方-1)。
在节点1放下一个小球,它会往下落。每个内结点都有一个状态(开或关),初始时,每个内结点都处于关闭状态,当小球经过一个内结点时,开关状态会改变。当为开状态时,小球向左落下;当为关状态时,小球向下落下,直到走到叶子结点。
______________________________________________________________
输入树的深度D,和小球数量I
输出第I个小球落到的结点编号 Continue reading