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

做公司网站详细步骤百度官方推广

做公司网站详细步骤,百度官方推广,网站迁移到别的服务器要怎么做,wordpress 信息分类模板1.题目要求: 给定一个二叉树:struct Node {int val;Node *left;Node *right;Node *next; } 填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL 。初始状态下,所有 ne…

1.题目要求:

给定一个二叉树:struct Node {int val;Node *left;Node *right;Node *next;
}
填充它的每个 next 指针,让这个指针指向其下一个右侧节点。如果找不到下一个右侧节点,则将 next 指针设置为 NULL 。初始状态下,所有 next 指针都被设置为 NULL

在这里插入图片描述
2.做题步骤:
(1)先创建好队列结构体,入队函数,出队函数:

//创建队列结构体
typedef struct queue{struct TreeNode* value;struct queue* next1;
}queue_t;
//入队
void push(queue_t** head,struct Node* data){queue_t* newnode = (queue_t*)malloc(sizeof(queue_t));newnode->value = data;newnode->next1 = NULL;if(*head == NULL){*head = newnode;return;}queue_t* tail = *head;while(tail->next1 != NULL){tail = tail->next1;}tail->next1 = newnode;
}
//出队
struct Node* pop(queue_t** head){struct TreeNode* x = (*head)->value;(*head) = (*head)->next1;return x;
}

(2)设置变量,进行层序遍历:

if(root == NULL){return NULL;}int count = 1;//当前行的节点数int nextcount = 0;//下一行的结点数int size = 0;//队列的结点数量queue_t* quence = NULL;push(&quence,root);size++;//开始层序遍历while(size != 0){for(int i = 0;i < count;i++){struct Node* temp = pop(&quence);size--;if(i == count - 1){temp->next = NULL;}else{temp->next = quence->value;}if(temp->left != NULL){push(&quence,temp->left);size++;nextcount++;}if(temp->right != NULL){push(&quence,temp->right);size++;nextcount++;}}count = nextcount;nextcount = 0;}

全部代码:

/*** Definition for a Node.* struct Node {*     int val;*     struct Node *left;*     struct Node *right;*     struct Node *next;* };*/
//创建队列结构体
typedef struct queue{struct TreeNode* value;struct queue* next1;
}queue_t;
//入队
void push(queue_t** head,struct Node* data){queue_t* newnode = (queue_t*)malloc(sizeof(queue_t));newnode->value = data;newnode->next1 = NULL;if(*head == NULL){*head = newnode;return;}queue_t* tail = *head;while(tail->next1 != NULL){tail = tail->next1;}tail->next1 = newnode;
}
//出队
struct Node* pop(queue_t** head){struct TreeNode* x = (*head)->value;(*head) = (*head)->next1;return x;
}
struct Node* connect(struct Node* root) {if(root == NULL){return NULL;}int count = 1;//当前行的节点数int nextcount = 0;//下一行的结点数int size = 0;//队列的结点数量queue_t* quence = NULL;push(&quence,root);size++;//开始层序遍历while(size != 0){for(int i = 0;i < count;i++){struct Node* temp = pop(&quence);size--;if(i == count - 1){temp->next = NULL;}else{temp->next = quence->value;}if(temp->left != NULL){push(&quence,temp->left);size++;nextcount++;}if(temp->right != NULL){push(&quence,temp->right);size++;nextcount++;}}count = nextcount;nextcount = 0;}return root;
}

好了,这就是我的全部代码了,大家如果觉得好的话,给个免费的赞吧,谢谢了^ _ ^

http://www.zhongyajixie.com/news/42313.html

相关文章:

  • 团购网站怎么做廊坊seo优化
  • 信息技术转移网站建设南昌seo营销
  • 怎么看网站是否被k过网络销售技巧
  • 网站模版怎么用广州seo好找工作吗
  • 武汉企业网站建设百度网盘搜索引擎入口在哪里
  • 做外贸批发网站是哪个seo网站查询工具
  • 大连市营商环境建设局网站网上企业推广
  • 兼职做网站挣钱么免费网络推广公司
  • 给手机做网站的公司有哪些湖南正规seo公司
  • 汕头市国外网站建设公司百度广告电话号码
  • 做阿里巴巴网站费用吗seo网站培训
  • 到那里找做网站的兼职今日刚刚发生的新闻
  • 那些网站可以上传自己做的视频百度链接提交入口
  • 上海wordpress建站google seo怎么做
  • 建设网站证书不受信任视频剪辑培训班一般学费多少
  • 加盟建筑分公司靠谱吗广州推动优化防控措施落地
  • 建设网站需要多少钱东莞疫情最新通告
  • 加强网站热线平台建设迅雷磁力链bt磁力天堂下载
  • 有做敦煌网站的吗seo排名专业公司
  • wordpress加密页面北京seo分析
  • 青岛开发区制作网站公司营销型网站建设题库
  • 做网站和做系统哪个难自助发外链网站
  • 如何构思公司网站郑州seo顾问热狗hotdoger
  • 学校做网站一般多少钱seo流量
  • shopex网站搬家如何注册自己的网站
  • 企业做网站优劣超级外链工具
  • 上海黄浦 网站制作哪里注册域名最便宜
  • wordpress做购物网站服装品牌营销策划方案
  • 适合毕设做的简单网站怎么注册自己的网站域名
  • 东莞贸易公司寮步网站建设价格洛阳seo博客