重写了PrintState函数,A通过

This commit is contained in:
2022-06-03 12:41:44 +08:00
parent c85d1f3049
commit 6db5438a94
4 changed files with 59 additions and 15 deletions

View File

@@ -147,7 +147,52 @@ rail_node_t *ReadConfigFile()
}
}
void PrintState(char *str)
void PrintState()
{
int count, flag = 1; //flag用于标记为使下面第一个循环能够进入
rail_node_t *p = NULL;
char target[25], clockwise[25], counterclockwise[25];
for (count = 0, p = rails; flag == 1 || p != rails; p = p->next_node, count++)
{
flag=0;
target[count] = '0';
clockwise[count] = '0';
counterclockwise[count] = '0';
} //遍历轨道链表将所有站点初始化为0无任何请求
target[count] = '\0';
clockwise[count] = '\0';
counterclockwise[count] = '\0';
bus_query_t *t = NULL;
int i;
for (t = queries; t != NULL; t = t->next_node)
{
i = t->node->id - 1;
if (t->type == 0)
{
clockwise[i] = '1';
}
else if(t->type==BUS_COUNTER_CLOCK_WISE)
{
counterclockwise[i] = '1';
}
else if(t->type==BUS_TARGET)
{
target[i] = '1';
}
} //遍历请求链表将有请求的站点按照不同类型标记为1
printf("TIME:%d\n", bus_time);
printf("BUS:\n");
printf("position:%d\n", GetBusPosition());
printf("target:%s\n", target);
printf("STATION:\n");
printf("clockwise:%s\n", clockwise);
printf("counterclockwise:%s\n", counterclockwise);
}
void PrintStateInner(char *str)
{
memset(str, 0, 150);
@@ -165,7 +210,7 @@ void PrintState(char *str)
target[count] = '\0';
clockwise[count] = '\0';
counterclockwise[count] = '\0';
bus_query_t *t = NULL;
int i;
for (t = queries; t != NULL; t = t->next_node)