2022-05-06 11:55:30 +08:00
|
|
|
#include "rail.h"
|
|
|
|
|
2022-05-13 11:41:00 +08:00
|
|
|
rail_node_t *rails = NULL;
|
2022-05-08 11:48:04 +08:00
|
|
|
|
|
|
|
int add(int a, int b)
|
|
|
|
{
|
|
|
|
return a+ b;
|
2022-05-17 21:15:19 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
rail_node_t *CreateRails(int length, int node_num)
|
|
|
|
{
|
|
|
|
/**
|
|
|
|
* 表示轨道的头节点
|
|
|
|
*/
|
|
|
|
rail_node_t *head = NULL;
|
|
|
|
rail_node_t *node = NULL;
|
|
|
|
|
|
|
|
head = (rail_node_t*) malloc(sizeof (rail_node_t));
|
|
|
|
head->id = 1;
|
|
|
|
head->last_node_distance = length;
|
|
|
|
head->next_node_distance = length;
|
|
|
|
|
|
|
|
node = head;
|
|
|
|
// 循环创建每一个节点
|
|
|
|
for(int i = 2; i <= node_num; i++)
|
|
|
|
{
|
|
|
|
rail_node_t *p = (rail_node_t*) malloc(sizeof (rail_node_t));
|
|
|
|
|
|
|
|
p->id = i;
|
|
|
|
p->last_node_distance = length;
|
|
|
|
p->next_node_distance = length;
|
|
|
|
p->last_node = node;
|
|
|
|
node->next_node = p;
|
|
|
|
node = p;
|
|
|
|
}
|
|
|
|
|
|
|
|
// 循环结束时node就是最后一个节点
|
|
|
|
node->next_node = head;
|
|
|
|
head->last_node = node;
|
|
|
|
|
|
|
|
return head;
|
2022-05-08 11:48:04 +08:00
|
|
|
}
|