void InitLine() //初始化航线信息 { airline *p,*q; L=(airline *)malloc(sizeof(airline)); L->booked=NULL; L->wait=NULL; L->next=NULL; strcpy(L->end_addr,"00000000"); strcpy(L->line_num,"000"); strcpy(L->plant_num,"0000000"); L->day=L->left=L->total=0; q=L; p=(airline *)malloc(sizeof(airline)); p->booked=NULL; p->wait=NULL; strcpy(p->end_addr,"天津"); strcpy(p->line_num,"004"); strcpy(p->plant_num," 3667894"); p->day=4; p->left=120; p->total=120; p->next=q->next; q->next=p; p=(airline *)malloc(sizeof(airline)); p->booked=NULL; p->wait=NULL; strcpy(p->end_addr,"广州"); strcpy(p->line_num,"003"); strcpy(p->plant_num,"4558934"); p->day=3; p->left=120; p->total=120; p->next=q->next; q->next=p; p=(airline *)malloc(sizeof(airline)); p->booked=NULL; p->wait=NULL; strcpy(p->end_addr,"上海"); strcpy(p->line_num,"002"); strcpy(p->plant_num,"2682154"); p->day=2; p->left=120; p->total=120; p->next=q->next; q->next=p; p=(airline *)malloc(sizeof(airline)); p->booked=NULL; p->wait=NULL; strcpy(p->end_addr,"北京"); strcpy(p->line_num,"001"); strcpy(p->plant_num," 2586934"); p->day=1; p->left=120; p->total=120; p->next=q->next; q->next=p; }
时间: 2024-03-11 15:45:11 浏览: 214
Linux实验八计划任务管理.doc
这是一个C语言的函数,用于初始化航线信息。该函数首先创建一个空的头结点L,并将其初始化。然后创建多个航线信息,每个航线信息都会被创建为一个新的节点p,并且将其插入到链表中,使得链表中的节点按照航班的日期从小到大排序。每个节点中都包含了航班的目的地、航班号、飞机号、出发日期、余票数量和总票数等信息。该函数的作用是为航班订票系统提供初始的航班信息。
阅读全文