/*Copyright (c)2017,烟台大学计算机与控制工程学院
*All rights reservrd.
*作者:王华慧
*完成时间:2017年12月21日
*版本号:v1.0
*问题描述:航空客运订票系统
-
-
-
-
-
-
-
-
-
-
#pragma once
#ifndef FK_H_INCLUDED
#define FK_H_INCLUDED
#define MAXSIZE 6 /*定义航线量的最大值*/
typedef struct waiting
{
char name[10];/*姓名*/
int wait_ask_number;/*订票量*/
struct waiting *next;
}qnode, *qptr;
typedef struct pqueue
{
qptr front;/*等候替补客户名单域的头指针*/
qptr rear;/*等候替补客户名单域的属指针*/
}linkqueue;
typedef struct ordered_people
{
char name[10];/*客户姓名*/
char zheng[50];
int ordering_number;/*订票量*/
int grade;/*舱位等级*/
struct ordered_people *next;
}linklist;
typedef struct airline
{
char end_station[10];/*终点站名 */
char air_num[10];/*航班号*/
char plane_num[10];/*飞机号*/
char day[7];/*飞行周日(星期几)*/
int people_quota;/*乘员定额*/
int more_ticket;/*余票量*/
linklist *order;/*乘员名单域,指向乘员名单链表的头指针*/
linkqueue wait;/*等候替补的客户名单域,分别指向排队等候名单队头队尾的指针*/
}lineinfo;/*在后面加,*start的意思是定义一种start类型,跟int型一样。*/
void list(airline *&start);
void search(airline *&start);
struct airline *find_air_num(airline *&start);
void prtlink(airline *&start);
void ordering(airline *&start);
void return_ticket(airline *&start);
int menu_select();
#endif // FK_H_INCLUDED
-
-
-
-
-
-
-
-
-
-
#include "fk.h"
#include <stdio.h>
#include <iostream>
#include <string.h>
#include <malloc.h>
using namespace std;
void list(airline *&start)/*打印全部航线信息*/
{
void display(struct airline *info);
struct airline *info;
int i = 0;
info = start;
printf("终点站名\t航班号\t飞机号\t飞行周日\t乘员定额\t余票量\n");
while (i<MAXSIZE) {
display(info);
info++;
i++;
}
printf("\n\n");
}
void display(struct airline *info)
/*打印每条航线的基本信息*/
{
printf("%8s\t%3s\t%s\t%4s\t\t%3d\t%10d\n", info->end_station, info->air_num, info->plane_num, info->day, info->people_quota, info->more_ticket);
}
void search(airline *&start)
/*根据客户提出的终点站名输出航线信息*/
{
struct airline *info, *find_air_num();
char name[10];
int i = 0;
info = start;
printf("请输入终点站名:");
scanf("%s", name);
printf("终点站名\t航班号\t飞机号\t飞行周日\t乘员定额\t余票量\n");
while (i<MAXSIZE) {
if (!strcmp(name, info->end_station))/*strcmp函数是比较两个字符串,相同的话返回0*/
display(info);
info++;
i++;
}
if (i>MAXSIZE)
printf("对不起,该航线未找到!\n");
}
struct airline *find_air_num(airline *&start)
/*根据系统提出的航班号查询并以指针形式返回*/
{
struct airline *info;
char number[10];
int i = 0;
info = start;
printf("请输入航班号:");
scanf("%s", number);
while (i<MAXSIZE) {
if (!strcmp(number, info->air_num)) return info;
info++;
i++;
}
printf("对不起,该航线末找到!\n");
return NULL;
}
void prtlink(airline *&start)
/*打印订票乘员名单域的客户名单信息*/
{
linklist *p;
struct airline *info;
info = find_air_num(start);
p = info->order;
if (p != NULL) {
printf("客户姓名 订票数额 舱位等级\n");
while (p) {
printf("%s\t\t%d\t%d\n", p->name, p->ordering_number, p->grade);
p = p->next;
}
}
else
printf("该航线没有客户信息!!\n");
}
linkqueue appendqueue(linkqueue q, char name[], int amount)
/*增加排队等候的客户名单域*/
{
qptr p = (qptr)malloc(sizeof(qnode));
strcpy(p->name, name);
p->wait_ask_number = amount;
p->next = NULL;
if (q.front == NULL)/*若原排队等候客户名单域为空*/
q.front = p;
else
q.rear->next = p;
q.rear = p;
return q;
}
linklist *insertlink(linklist *head, int amount, char name[], int grade)
/*增加订票乘员名单域的客户信息*/
{
linklist *p1, *p;
p1 = head;
p = (linklist *)malloc(sizeof(linklist));
if (!p) { printf("\n系统出现错误\n"); return NULL; }
strcpy(p->name, name);
p->order