Goodbye,T-MAC!
Monday, 7. May 2007, 00:32:58
HongLiang
Thursday, 10. May 2007, 12:41:11
Monday, 7. May 2007, 00:32:58
Sunday, 6. May 2007, 11:16:39
#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
Sunday, 6. May 2007, 07:53:50
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)));
}
好累阿Showing posts 1 - 5 of 12.
对本站的速度感觉如何?
Total: 1 vote
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
|
| ||||||
| 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 | 30 | 31 | |||
UBUNTU中文主页
UBUNTU官方网站