问题:判断二叉树是否为镜像二叉树分析:递归判断,根节点单独判断,然后递归左结点和右结点,之后每次一起递归左结点的左结点和右结点的右结点比较,左结点的右结点和右结点的左结点比较/** * Definition for binary tree * struct TreeNode { * int ...
分类:
其他好文 时间:
2014-08-04 17:27:27
阅读次数:
175
使用两个指针,和判断一个链表是否形成环类似
代码:
#include
#include
using namespace std;
typedef struct node {
int data;
struct node *next ;
}Node,*pNode;
void creatNode( pNode &pHead ){
bool isFirst=true;
pNode p...
分类:
其他好文 时间:
2014-08-04 06:14:16
阅读次数:
194
~~~~
二维的最长上升子序列。n^2算法居然可以水过。。
就不多说了,排个序,然后DP。
题目链接:http://poj.org/problem?id=1609
~~~~
#include
#include
#include
#include
#define N 11111
using namespace std;
struct node
{
int l,m;
}b[N];
...
分类:
其他好文 时间:
2014-08-04 02:07:06
阅读次数:
232
先排序后二分。 1 #include 2 #include 3 #include 4 #include 5 using namespace std; 6 7 #define MAXN 1005 8 9 typedef struct {10 int x, y;11 } node_s...
分类:
其他好文 时间:
2014-08-04 01:52:36
阅读次数:
323
/* DNS 头定义 */struct dnshdr{unsigned short id;unsigned short flags;unsigned short qdcount;unsigned short ancount;unsigned short nscount;unsigned short ...
分类:
其他好文 时间:
2014-08-04 01:40:46
阅读次数:
378
??
1.编写头文件
#define
_CRT_SECURE_NO_WARNINGS
//#pragmawarning(disable:4996)
#include
#include
#include
struct
CString
{
char *p;
//保存字符串首地址
i...
分类:
编程语言 时间:
2014-08-03 23:27:26
阅读次数:
557
??
1.编写头文件
#define
datatype
int
struct
statcknode
{
int
num;
//编号
datatype
data;
//数据
struct
statcknode *pNext;//指针域
};
...
分类:
其他好文 时间:
2014-08-03 23:25:46
阅读次数:
285
??
??
编写头文件
struct
queue
{
int
num;
//代表数据
int
high;
//优先级1111
struct
queue *pNext;//存储下一个节点的地址
};
typedef
struct
queue
Q...
分类:
其他好文 时间:
2014-08-03 23:24:26
阅读次数:
372
很自然想起来递归:
代码:
#include
#include
using namespace std;
typedef struct tree1{
int data;
struct tree1 * lchild;
struct tree1 * rchild;
}Tree,* pTree;
void createTree(pTree & p){
int temp ;
scan...
分类:
其他好文 时间:
2014-08-03 23:23:58
阅读次数:
267
宏CONTAINING_RECORD的用处其实还是相当大的, 而且很是方便, 它的主要作用是: 根据结构体中的某成员的指针来推算出该结构体的指针! 下面从一个简单的例子开始说起: 我们定义一个结构体, 同时类型化:typedef struct{ int a; int b; ...
分类:
其他好文 时间:
2014-08-03 23:13:36
阅读次数:
304