本文整理汇总了C++中PrintTree函数的典型用法代码示例。如果您正苦于以下问题:C++ PrintTree函数的具体用法?C++ PrintTree怎么用?C++ PrintTree使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了PrintTree函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: PrintTree
void PrintTree(struct Node *root)
{ // Perform Inorder Traversal of tree
if(root==0) { return; }
PrintTree(root->Left);
printf(" %d ",root->Data);
PrintTree(root->Right);
}
开发者ID:rajan96,项目名称:AlgoXtreme,代码行数:7,代码来源:Morris+Traversal.cpp
示例2: Test2
// 测试二叉树:出叶子结点之外,左右的结点都有且只有一个左子结点
// 8
// 7
// 6
// 5
// 4
void Test2()
{
printf("=====Test2 starts:=====\n");
BinaryTreeNode* pNode8 = CreateBinaryTreeNode(8);
BinaryTreeNode* pNode7 = CreateBinaryTreeNode(7);
BinaryTreeNode* pNode6 = CreateBinaryTreeNode(6);
BinaryTreeNode* pNode5 = CreateBinaryTreeNode(5);
BinaryTreeNode* pNode4 = CreateBinaryTreeNode(4);
ConnectTreeNodes(pNode8, pNode7, NULL);
ConnectTreeNodes(pNode7, pNode6, NULL);
ConnectTreeNodes(pNode6, pNode5, NULL);
ConnectTreeNodes(pNode5, pNode4, NULL);
PrintTree(pNode8);
printf("=====Test2: MirrorRecursively=====\n");
MirrorRecursively(pNode8);
PrintTree(pNode8);
printf("=====Test2: MirrorIteratively=====\n");
MirrorIteratively(pNode8);
PrintTree(pNode8);
DestroyTree(pNode8);
}
开发者ID:2015winter,项目名称:interview,代码行数:32,代码来源:MirrorOfBinaryTree.cpp
示例3: SimulateCoalescentTree
void SimulateCoalescentTree(int *method,int *sample,int *current,int *ancestral,int *time) {
int max_nodes;
Parameters P;
FILE *treefile;
GetRNGstate();
P.method = *method;
P.n = *sample;
P.current = *current;
P.ancestral = *ancestral;
P.time = *time;
max_nodes = 2 * P.n - 1; // This is the maximum number of nodes in the complete genealogy
list = (struct Node **) malloc (P.n * sizeof (struct Node *)); // These are the pointers to the remaining lineages
tree = (struct Node *) malloc (max_nodes * sizeof(struct Node)); // This contains the full genealogy
treefile = fopen(TREEFILE,"w");
if (P.method == 0) {
BuildTreeGenerations(P); // Give a sample of genes from a (generation-by-generation) coalescent alogrithm with mutations
PrintTree(&tree[nbr_nodes - 1],treefile);
} else if (P.method == 1) {
BuildTreeHudson(P); // Give a sample of genes from a (generation-by-generation) coalescent alogrithm with mutations
PrintTree(&tree[2 * P.n - 2],treefile);
}
fclose(treefile);
free(tree); // free the memory allocated for the structures 'tree', 'sample', and 'list'
free(list);
PutRNGstate();
}
开发者ID:rforge,项目名称:coalescer,代码行数:27,代码来源:SimulateCoalescentTree.c
示例4: Test1
// ====================测试代码====================
// 测试完全二叉树:除了叶子节点,其他节点都有两个子节点
// 8
// 6 10
// 5 7 9 11
void Test1()
{
printf("=====Test1 starts:=====\n");
BinaryTreeNode* pNode8 = CreateBinaryTreeNode(8);
BinaryTreeNode* pNode6 = CreateBinaryTreeNode(6);
BinaryTreeNode* pNode10 = CreateBinaryTreeNode(10);
BinaryTreeNode* pNode5 = CreateBinaryTreeNode(5);
BinaryTreeNode* pNode7 = CreateBinaryTreeNode(7);
BinaryTreeNode* pNode9 = CreateBinaryTreeNode(9);
BinaryTreeNode* pNode11 = CreateBinaryTreeNode(11);
ConnectTreeNodes(pNode8, pNode6, pNode10);
ConnectTreeNodes(pNode6, pNode5, pNode7);
ConnectTreeNodes(pNode10, pNode9, pNode11);
PrintTree(pNode8);
printf("=====Test1: MirrorRecursively=====\n");
MirrorRecursively(pNode8);
PrintTree(pNode8);
printf("=====Test1: MirrorIteratively=====\n");
MirrorIteratively(pNode8);
PrintTree(pNode8);
DestroyTree(pNode8);
}
开发者ID:2015winter,项目名称:interview,代码行数:32,代码来源:MirrorOfBinaryTree.cpp
示例5: PrintTree
void MSTree::PrintTree(MSTreeNode* rt)
{
if (rt==NULL) return;
rt->PrintNode(); // call PrintNode, print out the NormD
PrintTree(rt->LeftChild);
PrintTree(rt->RightChild);
}
开发者ID:weiyangedward,项目名称:Brownian-Motion,代码行数:7,代码来源:MSTree.cpp
示例6: main
int main(int argc, char *argv[])
{
BiTree *root1, *root2;
BiTree *tmp;
char temp[20];
int flag = 0;
printf("请输入第一棵书\n");
root1 = CreatTree_char(root1);
printf("创建成功\n");
PrintTree(root1, 1);
changes(root1);
printf("\n\n\n");
PrintTree (root1, 1);
// Print(root1, 1);
//CountParent(root1, &flag);
// printf("个数为%d\n", flag);
return EXIT_SUCCESS;
}
开发者ID:Gaoyuan0710,项目名称:Datatructures,代码行数:25,代码来源:BiTree4.c
示例7: PrintTree
void PrintTree(BNode* tree, unsigned int printLevel = 0)
{
for (unsigned int i = 0; i < printLevel; i++)
{
printf(" ");
}
if (printLevel > 0)
{
printf("+");
}
if (!tree)
{
printf("(null)\n");
return;
}
std::string output = "";
output += "(";
output += std::to_string(printLevel);
output += ")";
output += "Name: " + tree->name;
output += (tree->sibling ? " : Sibling: " + tree->sibling->name : "");
output += "\n";
printf("%s", output.c_str());
unsigned int nextLevel = printLevel + 1;
PrintTree(tree->right, nextLevel);
PrintTree(tree->left, nextLevel);
}
开发者ID:seanhaneberg,项目名称:breadthLink,代码行数:34,代码来源:breadthLinkApp.cpp
示例8: PrintTree
void PrintTree(const BinNode *p){
if ( p != NULL ){
PrintTree(p->left);
printf("%s\n",p->name);
PrintTree(p->right);
}
}
开发者ID:ikasoumen4,项目名称:ScientificCalculator,代码行数:7,代码来源:binary_search_tree.c
示例9: PrintTree
void PrintTree(BinNode *p)
{
if (p != NULL){
PrintTree(p->left);
PrintData(p->data);
PrintTree(p->right);
}
}
开发者ID:hzd02765,项目名称:meikai,代码行数:8,代码来源:10-04.c
示例10: PrintTree
// Skriv ut trädet
void PrintTree(objekt *x)
{
if(x!=NULL)
{
PrintTree(x->left);
printf("%d ",x->nyckel);
PrintTree(x->right);
}
}
开发者ID:Oberheim,项目名称:algodat,代码行数:10,代码来源:BinSokTree.c
示例11: PrintTree
//for testing
void Encoding::PrintTree(node* tree){
cout << tree->letter << " at weight " << tree->weight << endl;
if (tree->leftChild != NULL){
PrintTree(tree->leftChild);
}
if (tree->rightChild != NULL){
PrintTree(tree->rightChild);
}
}
开发者ID:wcastil,项目名称:Huffman-Encoding,代码行数:10,代码来源:encoding.cpp
示例12: PrintTree
void PrintTree(BinaryTreeNode* pRoot) {
if (pRoot != NULL) {
PrintTreeNode(pRoot);
if(pRoot->m_pLeft != NULL)
PrintTree(pRoot->m_pLeft);
if(pRoot->m_pRight != NULL)
PrintTree(pRoot->m_pRight);
}
}
开发者ID:irwenqiang,项目名称:inverview-algo,代码行数:9,代码来源:BinaryTree.cpp
示例13: PrintTree
void PrintTree(AvlTree T)
{
if (T)
{
cout << T->Element << " ";
PrintTree(T->Left);
PrintTree(T->Right);
}
}
开发者ID:oceanjaya,项目名称:DataStructurePractice,代码行数:9,代码来源:TestAvlTree.cpp
示例14: main
int main(int argc, char *argv[]) {
struct node* root = NULL;
struct nodeNumber* rootNumber = NULL;
time_t inicio, final;
time(&inicio);
if (argc != 3) {
fprintf(stderr, "Error: Problem with the number of parameters\n");
fprintf(stderr, " on the command line\n");
fprintf(stderr, "Use:\n");
fprintf(stderr, " dicttool option 'file_in' > 'file_out'\n");
fprintf(stderr, "option:\n");
fprintf(stderr, " 1 to seek words only\n");
fprintf(stderr, " 2 to check urls\n");
fprintf(stderr, " 3 to find numberss\n");
fprintf(stderr, " 4 to seek only words and counting\n");
fprintf(stderr, " 5 to check urls and counting\n");
fprintf(stderr, " 6 to check numbers and counting\n");
exit(8);
};
int option = atoi(argv[1]);
switch (option) {
case 1:
PrintTree(ScanWords(argv[2]));
break;
case 2:
PrintTree(ScanURL(argv[2]));
break;
case 3:
PrintNumbers(ScanNumbers(argv[2]));
break;
case 4:
PrintTreeCount(ScanWords(argv[2]));
break;
case 5:
PrintTreeCount(ScanURL(argv[2]));
break;
case 6:
PrintNumbersCount(ScanNumbers(argv[2]));
break;
default: {
fprintf(stderr, "option:\n");
fprintf(stderr, " 1 to seek words only\n");
fprintf(stderr, " 2 to check urls\n");
fprintf(stderr, " 3 to find numberss\n");
fprintf(stderr, " 4 to seek only words and counting\n");
fprintf(stderr, " 5 to check urls and counting\n");
fprintf(stderr, " 6 to check numbers and counting\n");
}
}
time(&final);
double diff = difftime(final, inicio);
printf("It took %.2lf seconds to run\n", diff);
return (0);
}
开发者ID:0unit,项目名称:dictionaryTool,代码行数:57,代码来源:main.c
示例15: PrintTree
void PrintTree (BinTree *T) //递归调用 前序遍历
{
if (T != NULL )
{
printf("%d \t" , T->data );
PrintTree(T->Left);
// printf("%d \t" , T->data ); //中序遍历
PrintTree(T->Right);
}
}
开发者ID:waten1992,项目名称:Create_Base_DataStructure,代码行数:10,代码来源:Binary_SearchTree_RecursionPrint_with_Non.cpp
示例16: PrintTree
void UndoEngine::PrintTrees()
{
std::stringstream cstr;
cstr << "OldTree: " << endl;
PrintTree(m_oldtree.m_tree,cstr,0);
cstr << "NewTree: " << endl;
PrintTree(m_tree.m_tree,cstr,0);
debugprint(cstr.str());
cstr.clear();
}
开发者ID:DavidNicholls,项目名称:heekscad,代码行数:10,代码来源:UndoEngine.cpp
示例17: PrintTree
void PrintTree(TreeNode* tree, std::ofstream& outFile)
// Prints info member of items in tree in sorted order on outFile.
{
if (tree != NULL)
{
PrintTree(tree->left, outFile); // Print left subtree.
outFile << tree->info;
PrintTree(tree->right, outFile); // Print right subtree.
}
}
开发者ID:WarGravy,项目名称:OldProjects,代码行数:10,代码来源:adt4.cpp
示例18: PrintTree
void
PrintTree( SplayTree T )
{
if( T != NullNode )
{
PrintTree( T->Left );
printf( "%d ", T->Element );
PrintTree( T->Right );
}
}
开发者ID:mazilaile,项目名称:Tree,代码行数:10,代码来源:splay.c
示例19: PrintTree
void PrintTree(BitTree Boot,int nLayer) //按竖向树状打印的二叉树 //
{
int i;
if(Boot==NULL) return;
PrintTree(Boot->RChild,nLayer+1);
for(i=0;i<nLayer;i++)
printf(" ");
printf("%c\n",Boot->data);
PrintTree(Boot->LChild,nLayer+1);
}
开发者ID:Gaoyuan0710,项目名称:Datatructures,代码行数:10,代码来源:tmp.c
示例20: PrintTree
static void PrintTree (DirEntry_s *direntry, int indent)
{
if (!direntry) return;
if (Option.print) {
Indent(indent);
printf("%s %s\n", direntry->type == T_DIR ? "D" : "F",
direntry->name);
}
PrintTree(direntry->child, indent + 1);
PrintTree(direntry->sibling, indent);
}
开发者ID:taysom,项目名称:tau,代码行数:11,代码来源:dir.c
注:本文中的PrintTree函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论