在你立足处深挖下去,就会有泉水涌出~

HongLiang

Subscribe to RSS feed

Sticky post

BootsHL说:大家好,有事请留言:)

天阿 ,opera的Community终于修好了

大约昨天(5月9号)晚上8点多,opera的blog突然不好使了,怎么也上不去:worried: ,可能是让人黑了?怀疑中.......不过现在终于又可以上了:happy:

Goodbye,T-MAC!

因为姚明进入NBA,我喜欢上了T-MAC,他的35妙13分仍然是我看NBA最难忘的时刻,可惜阿,季候赛没什么关注的了,可能唯一会看看勇士的比赛,googbye,Tracy McGrady,下赛季见!worried

用QT4写的第一个hello 程序

因为c++我选择了linux,因为linux我选择了QT,因为QT,我发现我开始爱上了它:rolleyes:
这是我用QT写的第一个程序,留作纪念!

#include <QApplication>

#include <QLabel>



int main(int argc, char *argv[])

{

	QApplication app(argc, argv);

	QLabel label("<h1>hello, <font color=red>Qt!</font></h1>");

	label.show();

  	return app.exec();

}
                                                                                                                               


进入程序目录,终端输入如下:
$qmake -project
$qmake
$make
$./helloqt

关于树的一些操作

刚刚学习完树结构,也想做个总结,回顾一下知识.内容如下:
二叉树的遍历
1.中序递归遍历:
 
void inorder(tree_pointer ptr)
{
	if(ptr)
	{
		inorder(ptr->left_child);
		printf("%d",ptr->data);
		inorder(ptr->right_child);
	}
}                                                                                                                          

2.中序迭代遍历:
#define MAX_STACK_SIZE 100
void iter_inorder(tree_pointer ptr)
{
	int top = -1;
	tree_pointer stack[MAX_STACK_SIZE];
	for(; ; )
	{
		for(;node;node = node->left_child)
			add(&top,node);
		node = delete(&top);
		if(!node)
			break;
		printf("%d",node->data);
		node = node->right_child;
	}
}
                                                                                                                          

3.层序遍历:
void level_order(tree_pointer ptr)
{                                                                                                                          
	int front = rear = 0;
	tree_pointor queue[MAX_QUEUE_SIZE];
	if(!ptr)
		return ;	//空树
	addq(front,&rear,ptr);
	for(; ; )
	{
		ptr = deleteq(&front,rear);
		if(ptr)
		{
			printf("%d",ptr->data);
			if(ptr->left_child)
				addq(front,&rear,ptr->left_child);
			if(ptr->right_child)
				addq(front,&rear,ptr->right_child);
		}
		else
			break;
	}
}
                                                                                                                          

4.二叉树的复制:
实际上,二叉树的复制操作是一个后序的变形.
tree_pointer copy(tree_pointer original)
{
	tree_pointer temp;
	if(original)
	{
		temp = (tree_pointer)malloc(sizeof(node));
		if(IS_FULL(temp))
		{
			fprintf("内存不足!\n");
			return ;
		}
	temp->left_child = copy(original->left_child);
	temp->right_child = copy(original->right_child);
	temp->data = original->data;
	return temp;
	}
	else
		return NULL;
}
                                                                                                                          

5.判断二叉树相等:
相等包括结构相等并且相应的结点具有相同的信息.当然也包括空树.这个操作是通过修改前序遍历得到了!
int equal(tree_pointer first,tree_pointer second)
{
	return ((!first && !second) || (first && second && 
				(first->data == second->data) && 
				equal(first->left_child,second->left_child) && 
				equal(first->right_child,second->right_child)));
}
                                                                                                                          

好累阿:hat: ,喝口水,下面待续!
February 2012
M T W T F S S
January 2012March 2012
1 2 3 4 5
6 7 8 9 10 11 12
13 14 15 16 17 18 19
20 21 22 23 24 25 26
27 28 29