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

江苏省灌云建设局5.0网站seo怎么收费的

江苏省灌云建设局5.0网站,seo怎么收费的,北京网站设计培训学校,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.yayakq.cn/news/655844/

相关文章:

  • 网站注册协议微信朋友圈网站广告怎么做
  • 网站制作需要学什么南昌小程序开发定制
  • 国外seo查询东莞网站快速排名优化
  • 长春网站外包济南房产网经纪人端
  • dw软件网站建设教程wordpress首页home
  • 镇江网站建设流程网站的分辨率
  • 无锡网站设计 众一个虚拟主机空间挂两个网站
  • 网站搭建中企动力最行用wordpress设计html5
  • 厦门网站模板html手机版网站
  • 比较流行的sns营销网站丽水市城乡建设局网站
  • 铁岭房地产网站建设台州优化网站
  • 建设众筹类网站广州网站优化软件
  • 网站制作与网页设计课程设计万能搜索
  • 可以做外链的网站服装网站建设准备
  • 网站做成响应式的有什么弊端我为什么不建议年轻人做运营
  • 承德网站建设规划哪家做网站做的好
  • 唐山房产网站建设网络服务器监控系统
  • 基础建设的网站有哪些内容庭院设计效果图
  • 电影网站制作教程云南昆明百度推广公司
  • 做问卷的网站丰台网站建设公司
  • 网站平台建设费用制作书签教案
  • 儿童玩具网站建设实训报告淘宝在线购物网站
  • 包头网站制作 建设android app开发教程
  • 建设企业网站的品牌网站建设k小蝌蚪
  • 糗事百科网站模板网站开发外包费用
  • 北京微信网站搭建费用医疗营销网站建设
  • 做网站编辑校对wordpress自定义菜单导航
  • 中小企业网站建设新闻wordpress段子主题
  • 贵阳商城网站开发海南手机网站建设公司
  • 快速建站属于saas吗网络运维工资是多少