2013年4月15日

二叉排序树

摘要: #include <stdio.h>#include <stdlib.h>typedef struct node{ int data; node *lchild; node *rchild;}TreeNode;void InsertNode(TreeNode *&Node, int n){ if (Node == NULL) { Node = (TreeNode*)malloc(sizeof(TreeNode)); Node->data = n; Node->lchild = Node->rchild = NULL; } else { if ( 阅读全文

posted @ 2013-04-15 21:15 lzm风雨无阻 阅读(156) 评论(0) 推荐(0) 编辑

全排列的递归算法

摘要: #include <stdio.h>void DFS(int arr[], int n, int visited[], int result[], int row){ if (row >= n) { for (int i = 0; i < n; i++) { printf("%d ", result[i]); } printf("\n"); return; } for (int i = 0; i < n; i++) { if (visited[i] == 0) { visited[i] = 1; result[row] = 阅读全文

posted @ 2013-04-15 20:08 lzm风雨无阻 阅读(176) 评论(0) 推荐(0) 编辑

导航