当前位置: 首页 > wzjs >正文

新网站要多久收录什么是品牌vi设计

新网站要多久收录,什么是品牌vi设计,wordpress 仿主题,江苏优化网站公司三种表示法&#xff1a;双亲表示法&#xff0c;孩子表示法&#xff0c;孩子兄弟表示法 双亲表示法 //树结构——双亲表示法 #include <iostream>using namespace std;struct Tree {string data;Tree* parent; //双亲指针Tree* firstchild; //第一个孩子指针Tre…

三种表示法:双亲表示法,孩子表示法,孩子兄弟表示法

双亲表示法

//树结构——双亲表示法
#include <iostream>using namespace std;struct Tree
{string data;Tree* parent;       //双亲指针Tree* firstchild;   //第一个孩子指针Tree* nextsibling;  //下一个兄弟指针
};void CreateTree(Tree*&root,string data,Tree* parent)
{Tree* newtree= new Tree;newtree->data=data;newtree->parent=parent;newtree->firstchild=NULL;newtree->nextsibling=NULL;if(root==NULL){root=newtree;return;}if(parent!=NULL){//temp指向该父类的第一个孩子Tree* temp=parent->firstchild;//如果第一个孩子为空,添加为第一个孩子if (temp==NULL){parent->firstchild=newtree;}else{//不为空的情况下//如果该父类有兄弟,就遍历到最后一个兄弟,然后添加为兄弟while(temp->nextsibling!=NULL){temp=temp->nextsibling;}temp->nextsibling=newtree;}}
}//前序便利
void printTree(Tree* root){if(root==NULL){return;}else{cout<<root->data<<endl;printTree(root->firstchild);printTree(root->nextsibling);}}int main(){Tree* root=NULL;CreateTree(root,"root",NULL);CreateTree(root,"root->node1",root);CreateTree(root,"root->node2",root);CreateTree(root,"root->node3",root);CreateTree(root,"root->node1->node1",root->firstchild);CreateTree(root,"root->node1->node2",root->firstchild);CreateTree(root,"root->node2->node1",root->firstchild->nextsibling);CreateTree(root,"root->node3->node1",root->firstchild->nextsibling->nextsibling);cout<<"树的结构为:"<<endl;printTree(root);return 0;}

好吧这个其实是个综合的表示法,是孩子兄弟加上一个parent指针

孩子表示法

(虽然我感觉看这张图理解可能也会有点晕)

//孩子表示法
#include<iostream>using namespace std;
//这里要先声明,不然Childlist中引用会出错
struct TreeNode;/*
简单说一下这里的思路:
TreeNode结构体代表一个节点,data为数据,firstChild为指向第一个孩子的指针
一个节点的孩子我们用Childlist链表来表示,
链表中的每个节点都有一个指向TreeNode的指针和指向下一位的指针createTree函数创建一个新的节点并返回
addChild函数将返回的节点通过识别两个参数,
第一个是你想要插入位置的父节点,第二个是你想要插入的节点所有的节点都要先createTree再addChild,
*/struct Childlist{TreeNode* child;Childlist* next;
};struct TreeNode{string data;Childlist* firstChild;};TreeNode* createTree(string data){ TreeNode* newnode=new TreeNode();newnode->data=data;newnode->firstChild=NULL;return newnode;
}void addChild(TreeNode* parent,TreeNode* your_node){if(parent==NULL){return;}Childlist* newnode=new Childlist();newnode->child=your_node;newnode->next=NULL;if(parent->firstChild==NULL){parent->firstChild=newnode;}else{Childlist* temp=parent->firstChild;while(temp->next!=NULL){temp=temp->next;}temp->next=newnode;}}void printTree(TreeNode* root){if(root==NULL){return;}cout<<root->data<<endl;Childlist* temp=root->firstChild;while(temp!=NULL){printTree(temp->child);temp=temp->next;}
}int main(){//测试可看出为前序便利TreeNode* root=createTree("root");TreeNode* child1=createTree("root->child1");TreeNode* child2=createTree("root->child2");TreeNode* child3=createTree("root->child2->child3");TreeNode* child4=createTree("root->child1->child4");TreeNode* child5=createTree("root->child1->child4->child5");TreeNode* child6=createTree("root->child1->child4->child6");TreeNode* child7=createTree("root->child1->child7");addChild(root,child1);addChild(root,child2);addChild(child2,child3);addChild(child1,child4);addChild(child4,child5);addChild(child4,child6);addChild(child1,child7);printTree(root);return 0;
}

孩子兄弟表示法

//孩子兄弟表示法
//其实原理和孩子表示法差不多,只不过是把孩子表示法中的链表提到了节点上
//类似于一个二叉树
//还有就是感觉先定义然后再链接感觉更直观一点
#include<iostream>using namespace std;struct TreeNode{string data;TreeNode* firstchild;TreeNode* next;
};TreeNode* createTree(string data){TreeNode* newnode = new TreeNode;newnode->data = data;newnode->firstchild = NULL;newnode->next = NULL;return newnode;
}void addNode(TreeNode* parent,TreeNode* your_node){if(parent->firstchild == NULL){parent->firstchild = your_node;}else{TreeNode* temp = parent->firstchild;while(temp->next != NULL){temp = temp->next;}temp->next = your_node;}}void printTree(TreeNode* root){if(root == NULL){return;}cout<<root->data<<endl;TreeNode* temp = root->firstchild;while(temp != NULL){printTree(temp);temp = temp->next;}
}int main(){TreeNode* root = createTree("root");TreeNode* node1 = createTree("root->ndoe1");TreeNode* node2 = createTree("root->node2");TreeNode* node3 = createTree("root->node2->node3");TreeNode* node4 = createTree("root->node2->node4");addNode(root,node1);addNode(root,node2);addNode(node2,node3);addNode(node2,node4);printTree(root);return 0;
}


文章转载自:

http://SqSxSqmo.wyjhq.cn
http://NaHzLmiw.wyjhq.cn
http://6nNFEH6Y.wyjhq.cn
http://DLy3nNCp.wyjhq.cn
http://O9Ve9MwF.wyjhq.cn
http://GSahU0vs.wyjhq.cn
http://0ArTZdk1.wyjhq.cn
http://DUIgrWMX.wyjhq.cn
http://IOjF5J5m.wyjhq.cn
http://8ddGkEBd.wyjhq.cn
http://EmwADdi4.wyjhq.cn
http://J6bvuiLD.wyjhq.cn
http://58gyEd4e.wyjhq.cn
http://Wsnos1ag.wyjhq.cn
http://dSNPDHRp.wyjhq.cn
http://0CPUeYyE.wyjhq.cn
http://rak7p9KP.wyjhq.cn
http://3aGKpgvF.wyjhq.cn
http://p1dag1q0.wyjhq.cn
http://UCcP0HTL.wyjhq.cn
http://8iGJuPyB.wyjhq.cn
http://FXsrctNi.wyjhq.cn
http://gYiM74iF.wyjhq.cn
http://KEb4ZwDO.wyjhq.cn
http://shJOqHcL.wyjhq.cn
http://uU0TtnVt.wyjhq.cn
http://w52QfUuD.wyjhq.cn
http://yqsK6U0E.wyjhq.cn
http://CCOTvcZZ.wyjhq.cn
http://UKlmYZfc.wyjhq.cn
http://www.dtcms.com/wzjs/628747.html

相关文章:

  • win10虚拟目录 做网站昆明建设局网站
  • 长春免费做网站建筑英才网和中国建筑人才网
  • 熊掌号 西安网站建设温州网吧什么时候恢复营业
  • 建设部网站一级建造师报名嘉定企业网站开发
  • 阿里云网站建设好了怎么如何设置标签 wordpress
  • 网站tag设计相关文章 wordpress插件
  • 面包机做面包网站英文购物网站模板
  • 民宿网站开发数据流图最便宜的视频网站建设
  • 建设专业网站公司智慧记免费官方下载
  • seo01网站今朝装饰
  • 电商运营 网站运营动漫做视频在线观看网站
  • 网站建设流程的怎样的婚庆公司网站建设总结
  • 狼雨seo网站排名查询建一个门户网站多少钱
  • 刚开始的网站开发公司佛山市建设工程有限公司
  • 高科技公司网站模板可以上传软件的网站
  • 网站建设意思ps做网站的效果图
  • 什么网站做h5沈阳seo关键词排名
  • 电商网站商品页的优化目标是什么查看网站备案号
  • 个体户能做网站备案吗西安网站建设网络公司
  • 网站媒体作风建设年工作总结黑彩网站怎么做
  • 网站推广见效快的方法做网站广告联盟赚钱
  • 刘涛做的婴儿玩具网站做网站建设需要做哪些工作
  • 做国外搞笑网站服务哪家好中医小程序定制
  • 东莞微信网站商城建设阿里云 拦截网站
  • 祥云平台英文网站wordpress显示评论者地理位置 浏览器
  • 小程序建站模板江西建设厅网站官网
  • 网站域名品牌怎么写淘宝网首页登录网页版
  • 免费行情软件网站直播广州越秀区天气预报
  • 企业网站建设晋升没有服务器建网站
  • 网站刚做好怎么做优化海安县城乡建设局网站