主题:放送航空售票系统源代码(已修正错误)
我们老师布置的作业,基本上完成了,现已完成,并修正了部分错误
注意事项,输入字符时不要包含空格,由于本人用的编译器有问题,gets函数不能正常工作,。如果想要输入字符串中包含空格,请自行将部分scanf改为gets.
程序采用链表和顺序表的混合设计
本人初学数据结构,希望与大家多多交流
如有问题请跟帖讨论
功能:可以输入姓名查询自己的航班信息
可以订票,退票
可以增加航班(设置了密码)
几个函数功能的描述
void init(flightmange* fl,char fn[][20],int fnum[],int tic[] ) 初始化航班信息
void printall(flightmange* fl,int *length)显示所有航班信息
void welcome()显示主界面
int findflight(flightmange *fl,int n,int *length)查询是否存在此航班号
void printselect(flightmange *fl,int i,int n)显示当前航班信息
void booktic(flightmange *fl,int *length)订票
flightdetail* findname(flightdetail *m,char na[]) 搜索指定用户名
void returntic(flightmange *fl,int *length)退票
void search(flightmange *fl,int *length)搜索指定用户的航班信息
void create(flightmange *fl,int *length)在原有的航班基础上添加新航班
#define N 5
#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"
#include "string.h"
typedef struct flightdetail
{
char customer[10];
int num;
struct flightdetail *next;
}flightdetail;
typedef struct flightmange
{
char name[20];
int booked;
int ticket;
int flightnum;
flightdetail *next;
}flightmange;
void init(flightmange* fl,char fn[][20],int fnum[],int tic[] )
{
int i;
flightdetail *fd;
for(i=0;i<N;i++)
{ fd=(flightdetail *)malloc(sizeof(flightdetail));
strcpy((fl[i]).name,fn[i]);
(fl[i]).booked=0;
(fl[i]).ticket=tic[i];
(fl[i]).flightnum=fnum[i];
(fl[i]).next=fd;
fd->next==NULL;
}
}
void printall(flightmange* fl,int *length)
{
int i;
printf("\tAll Flght Information\n\n");
printf("Flightname Flightnum All Sold Rest\n\n");
for(i=0;i<*length;i++)
{
printf("%-20s",(fl[i]).name);
printf(" %-8d",(fl[i]).flightnum);
printf(" %-5d",(fl[i]).ticket);
printf(" %-5d",(fl[i]).booked);
printf(" %-5d",(fl[i]).ticket-(fl[i]).booked);
printf("\n");
}
printf("\nPress Any Key to Return the System");
getch();
}
void welcome()
{
printf("\t\t\tTicket Mange System\n\n");
printf("\t1.Reset the System (Password Required)\n");
printf("\t2.Book Ticket(s)\n");
printf("\t3.Return Ticket(s)\n");
printf("\t4.Show All the Flight Information\n");
printf("\t5.Dispaly My Flights\n");
printf("\t6.Quit the System");
printf("\n\nPlease Enter a Num to Select an Item");
printf("\n\t\t\t\t\t\tDesigned By Yang Rida");
}
注意事项,输入字符时不要包含空格,由于本人用的编译器有问题,gets函数不能正常工作,。如果想要输入字符串中包含空格,请自行将部分scanf改为gets.
程序采用链表和顺序表的混合设计
本人初学数据结构,希望与大家多多交流
如有问题请跟帖讨论
功能:可以输入姓名查询自己的航班信息
可以订票,退票
可以增加航班(设置了密码)
几个函数功能的描述
void init(flightmange* fl,char fn[][20],int fnum[],int tic[] ) 初始化航班信息
void printall(flightmange* fl,int *length)显示所有航班信息
void welcome()显示主界面
int findflight(flightmange *fl,int n,int *length)查询是否存在此航班号
void printselect(flightmange *fl,int i,int n)显示当前航班信息
void booktic(flightmange *fl,int *length)订票
flightdetail* findname(flightdetail *m,char na[]) 搜索指定用户名
void returntic(flightmange *fl,int *length)退票
void search(flightmange *fl,int *length)搜索指定用户的航班信息
void create(flightmange *fl,int *length)在原有的航班基础上添加新航班
#define N 5
#include "stdio.h"
#include "stdlib.h"
#include "malloc.h"
#include "string.h"
typedef struct flightdetail
{
char customer[10];
int num;
struct flightdetail *next;
}flightdetail;
typedef struct flightmange
{
char name[20];
int booked;
int ticket;
int flightnum;
flightdetail *next;
}flightmange;
void init(flightmange* fl,char fn[][20],int fnum[],int tic[] )
{
int i;
flightdetail *fd;
for(i=0;i<N;i++)
{ fd=(flightdetail *)malloc(sizeof(flightdetail));
strcpy((fl[i]).name,fn[i]);
(fl[i]).booked=0;
(fl[i]).ticket=tic[i];
(fl[i]).flightnum=fnum[i];
(fl[i]).next=fd;
fd->next==NULL;
}
}
void printall(flightmange* fl,int *length)
{
int i;
printf("\tAll Flght Information\n\n");
printf("Flightname Flightnum All Sold Rest\n\n");
for(i=0;i<*length;i++)
{
printf("%-20s",(fl[i]).name);
printf(" %-8d",(fl[i]).flightnum);
printf(" %-5d",(fl[i]).ticket);
printf(" %-5d",(fl[i]).booked);
printf(" %-5d",(fl[i]).ticket-(fl[i]).booked);
printf("\n");
}
printf("\nPress Any Key to Return the System");
getch();
}
void welcome()
{
printf("\t\t\tTicket Mange System\n\n");
printf("\t1.Reset the System (Password Required)\n");
printf("\t2.Book Ticket(s)\n");
printf("\t3.Return Ticket(s)\n");
printf("\t4.Show All the Flight Information\n");
printf("\t5.Dispaly My Flights\n");
printf("\t6.Quit the System");
printf("\n\nPlease Enter a Num to Select an Item");
printf("\n\t\t\t\t\t\tDesigned By Yang Rida");
}