修改了PrintState函数

This commit is contained in:
Yerolling 2022-05-24 21:16:51 +08:00
parent f6ceaa1c7e
commit 2316e3144c

View File

@ -151,12 +151,13 @@ void PrintState(char *str)
{ {
memset(str, 0, 150); memset(str, 0, 150);
int count; int count, flag=1; //flag用于标记为使下面第一个循环能够进入
rail_node_t *p = NULL; rail_node_t *p = NULL;
char target[20], clockwise[20], counterclockwise[20]; char target[20], clockwise[20], counterclockwise[20];
for (count = 0, p = rails; p != NULL; p = p->next_node, count++) for (count = 0, p = rails; flag==1 || p != NULL; p = p->next_node, count++)
{ {
flag=0;
target[count] = '0'; target[count] = '0';
clockwise[count] = '0'; clockwise[count] = '0';
counterclockwise[count] = '0'; counterclockwise[count] = '0';