C语言航空售票系统Word格式.docx

上传人:b****4 文档编号:6229091 上传时间:2023-05-06 格式:DOCX 页数:17 大小:17.13KB
下载 相关 举报
C语言航空售票系统Word格式.docx_第1页
第1页 / 共17页
C语言航空售票系统Word格式.docx_第2页
第2页 / 共17页
C语言航空售票系统Word格式.docx_第3页
第3页 / 共17页
C语言航空售票系统Word格式.docx_第4页
第4页 / 共17页
C语言航空售票系统Word格式.docx_第5页
第5页 / 共17页
C语言航空售票系统Word格式.docx_第6页
第6页 / 共17页
C语言航空售票系统Word格式.docx_第7页
第7页 / 共17页
C语言航空售票系统Word格式.docx_第8页
第8页 / 共17页
C语言航空售票系统Word格式.docx_第9页
第9页 / 共17页
C语言航空售票系统Word格式.docx_第10页
第10页 / 共17页
C语言航空售票系统Word格式.docx_第11页
第11页 / 共17页
C语言航空售票系统Word格式.docx_第12页
第12页 / 共17页
C语言航空售票系统Word格式.docx_第13页
第13页 / 共17页
C语言航空售票系统Word格式.docx_第14页
第14页 / 共17页
C语言航空售票系统Word格式.docx_第15页
第15页 / 共17页
C语言航空售票系统Word格式.docx_第16页
第16页 / 共17页
C语言航空售票系统Word格式.docx_第17页
第17页 / 共17页
亲,该文档总共17页,全部预览完了,如果喜欢就下载吧!
下载资源
资源描述

C语言航空售票系统Word格式.docx

《C语言航空售票系统Word格式.docx》由会员分享,可在线阅读,更多相关《C语言航空售票系统Word格式.docx(17页珍藏版)》请在冰点文库上搜索。

C语言航空售票系统Word格式.docx

charname[N];

/*客户姓名*/

intdocument;

/*证件号,按证件号将客户信息写入文件*/

intplaneNum;

/*订票的航班号*/

/*订票数量*/

}Client;

/*客户结构*/

staticvoidInstruction(void);

/*菜单函数*/

staticvoidPlaneFile(void);

/*初始化使用文件*/

staticvoidClientFile(void);

/*初始化客户使用文件*/

staticvoidEnterPlane(void);

/*输入航班数据*/

staticvoidEnterClient(void);

/*输入客户数据*/

staticvoidSearchPlane(void);

/*查找航班信息*/

staticvoidSearchStyle(void);

/*查找航班的种类*/

staticvoidModifyPlane(void);

/*修改航班数据*/

staticvoidModifyStyle(void);

/*修改航班种类*/

staticvoidBuyTicket(void);

/*买票*/

staticvoidRefundTicket(void);

/*退票*/

staticvoidPrintPlane(void);

/*打印航班数据*/

staticvoidPrintClient(void);

/*打印客户数据*/

intmain(void)

intchoice;

Instruction();

scanf("

%d"

&

choice);

/*读取选项*/

while(choice)/*0退出*/

{

switch(choice)/*选择选项*/

case1:

PlaneFile();

/*初始化航班使用文件*/

break;

case2:

ClientFile();

case3:

EnterPlane();

case4:

EnterClient();

case5:

SearchPlane();

case6:

ModifyPlane();

case7:

BuyTicket();

case8:

RefundTicket();

case9:

PrintPlane();

/*打印所有航班信息*/

case10:

PrintClient();

/*打印所有客户信息*/

}

return0;

}

staticvoidInstruction(void)/*right*/

printf("

1-Initialplaneusefile(0-quit).\n"

);

/*1*/

2-Initialclientusefile.\n"

3-Enterplaneinformation.\n"

4-Enterclientinformation.\n"

5-Searchplaneinformation.\n"

6-Modifyplaneinformation.\n"

7-Buyticketfunction.\n"

8-Refundticktetfunction.\n"

9-Displayallplaneinformation.\n"

10-Displayallclientinformation.\n"

staticvoidPlaneFile(void)/*right*//*初始化航班使用文件*/

FILE*fp;

PlaneP={0,"

"

"

0.0,0.0,0};

/*初始化空数据*/

inti;

if((fp=fopen("

d:

\\hope\\plane"

wb"

))==NULL)/*创建2进制使用文件*/

planefilecreatefailure,pleasepressanykeyquit.\n"

getch();

exit

(1);

/*文件创建失败退出*/

for(i=1;

i<

=200;

i++)/*写入200个结构块*/

fwrite(&

P,sizeof(Plane),1,fp);

fclose(fp);

/*关闭使用文件*/

staticvoidClientFile(void)/*right*//*初始化客户使用文件*/

ClientC={0,"

0,0,0};

/*初始化客户数据*/

\\hope\\client"

))==NULL)/*创建2进制客户使用文件*/

clientfilecreatefailure,pleasepressanykeyquit.\n"

=100;

i++)/*创建100份客户数据空间*/

C,sizeof(Client),1,fp);

/*将初始化数据写入文件*/

/*关闭初始化使用文件*/

staticvoidEnterPlane(void)/*right*//*输入航班数据*/

PlaneP;

rb+"

))==NULL)/*用2进制方式打开文件*/

planefilecannotopen,pressanykeyquit.\n"

EnterP.acct(1-200)="

/*提示输入航班号*/

P.acct);

/*读取输入航班号*/

while(P.acct)/*输入0时停止输入*/

Enter:

P.uptime,P.downtime,P.upcity,P.downcity,P.ticket,P.discount,P.ticketNum.\n"

%s%s%s%s%f%f%d"

P.uptime,P.downtime,P.upcity,P.downcity,&

P.ticket,&

P.discount,&

P.ticketNum);

fseek(fp,(P.acct-1)*sizeof(Plane),SEEK_SET);

/*确定数据写入位置*/

/*将数据写入文件*/

EnterP.acct="

staticvoidEnterClient(void)/*right*//*输入客户数据*/

ClientC;

))==NULL)/*用2进制打开*/

clientfilecannotopen,pleasepressanykeyquit.\n"

EnterC.document(1-100)="

C.document);

/*读取证件号,按证件号写入文件*/

while(C.document)/*0时停止输入*/

EnterC.name.\n"

%s"

C.name);

/*读取客户姓名*/

C.Num=0;

/*定单号*/

C.planeNum=0;

C.ticketNum=0;

fseek(fp,(C.document-1)*sizeof(Client),SEEK_SET);

/*确定文件写入位置*/

/*数据写入文件*/

staticvoidSearchPlane(void)/*right*//*查找航班信息*/

intchoice,acct,tag=0;

charupcity[N],downcity[N];

/*起飞和降落城市*/

rb"

))==NULL)/*2进制只读方式打开文件*/

planefilecannotopen,pleasepressanykeyquit.\n"

SearchStyle();

/*查找航班种类*/

switch(choice)

EntersearchP.acct(1-200)="

acct);

/*读取要查找的航班号*/

while(!

feof(fp))

fread(&

/*读取文件中的数据*/

if(P.acct==acct)/*找到指定航班*/

Theplaneinformation.\n"

%-10s%-10s%-10s%-10s%-10s%-10s%-10s%-10s\n"

"

Account"

Uptime"

Downtime"

Upcity"

Downcity"

Ticket"

Discount"

TicketNum"

%-10d%-10s%-10s%-10s%-10s%-10.2f%-10.2f%-10d\n"

P.acct,P.uptime,P.downtime,P.upcity,P.downcity,

P.ticket,P.discount,P.ticketNum);

tag=1;

/*设置找到标记*/

}/*找到后使用break退出循环*/

Enterupcityanddowncity:

\n"

%s%s"

upcity,downcity);

/*读取起飞和降落城市*/

if(strcmp(P.upcity,upcity)==0&

&

strcmp(P.downcity,downcity)==0)

"

P.acct,P.uptime,P.downtime,P.upcity,P.downcity,P.ticket,P.discount,P.ticketNum);

}/*找到后退出*/

default:

Invalidenter.\n"

if(tag==0)/*没有找到指定航班数据*/

Nofoundspecityplaneinformation.\n"

staticvoidSearchStyle(void)/*right*//*查找航班的种类*/

1-planeaccountsearch.\n"

/*航班号进行查找*/

2-upcityanddowncitysearch.\n"

/*起飞和降落城市进行查找*/

staticvoidModifyPlane(void)/*right*//*修改航班数据*/

PlaneP,PE={0,"

/*PE为置空航班信息*/

intacct,choice,tag=0;

charselect;

))==NULL)/*以2进制读写方式打开*/

ModifyStyle();

/*选择修改种类*/

switch(choice)/*按修改种类对航班信息进行修改*/

/*删除指定航班信息*/

Enterdeleteplaneacct(1-200):

/*读取删除航班号*/

/*读取文件中数据*/

if(P.acct==acct)

Areyousuredeleteplaneinformation('

y'

-yes,'

n'

-no):

getchar();

%c"

select);

/*确定是否删除航班信息*/

if(select=='

fseek(fp,(acct-1)*sizeof(Plane),SEEK_SET);

PE,sizeof(Plane),1,fp);

/*将空信息写入文件*/

Thespecifyplaneinformationalreadydelete.\n"

else

Youcanceldeleterequire.\n"

/*找到标志*/

}/*while*/

/*修改指定航班信息*/

Entermodifyplaneacct(1-200):

/*读取修改航班号*/

if(P.acct==acct)/*找到指定修改航班号*/

/*打印指定航班信息*/

Areyousuremodifyplaneinformation('

Enternewplaneinformation.\n"

P.uptime,P.downtime,P.upcity,P.downcity,P.ticket,P.discount,P.ticketNum.\n"

P.uptime,P.downtime,P.upcity,P.downcity,&

Youcancelmodifyrequire.\n"

if(tag==0)

Sorry,Nofoundspecitymodifyplane.\n"

staticvoidModifyStyle(void)/*修改航班种类*/

1-Deletespecifyplaneinformation.\n"

2-Updataspecifyplaneinformation.\n"

staticvoidBuyTicket(void)/*客户买票*/

charname[N],select,upcity[N],downcity[N];

/*买票的客户名*/

FILE*fpp,*fpc;

展开阅读全文
相关资源
猜你喜欢
相关搜索
资源标签

当前位置:首页 > 解决方案 > 学习计划

copyright@ 2008-2023 冰点文库 网站版权所有

经营许可证编号:鄂ICP备19020893号-2