C语言编程火车订票系统源代码Word格式.docx

上传人:b****2 文档编号:15230699 上传时间:2022-10-28 格式:DOCX 页数:16 大小:18.16KB
下载 相关 举报
C语言编程火车订票系统源代码Word格式.docx_第1页
第1页 / 共16页
C语言编程火车订票系统源代码Word格式.docx_第2页
第2页 / 共16页
C语言编程火车订票系统源代码Word格式.docx_第3页
第3页 / 共16页
C语言编程火车订票系统源代码Word格式.docx_第4页
第4页 / 共16页
C语言编程火车订票系统源代码Word格式.docx_第5页
第5页 / 共16页
点击查看更多>>
下载资源
资源描述

C语言编程火车订票系统源代码Word格式.docx

《C语言编程火车订票系统源代码Word格式.docx》由会员分享,可在线阅读,更多相关《C语言编程火车订票系统源代码Word格式.docx(16页珍藏版)》请在冰豆网上搜索。

C语言编程火车订票系统源代码Word格式.docx

/*票数*/

};

/*订票人的信息*/

structman

charnum[10];

/*ID*/

charname[10];

/*姓名*/

/*需求的票数*/

/*定义火车信息链表的结点结构*/

typedefstructnode

structtraindata;

structnode*next;

}Node,*Link;

/*定义订票人链表的结点结构*/

typedefstructpeople

structmandata;

structpeople*next;

}bookMan,*bookManLink;

/*初始界面*/

voidprintInterface()

puts("

********************************************************"

);

*Welcometousethesystemofbookingtickets*"

*Youcanchoosetheoperation:

*"

*1:

Insertatraininformation*"

*2:

Inquireatraininformation*"

*3:

Bookatrainticket*"

*4:

Updatethetraininformation*"

*5:

Advicetoyouaboutthetrain*"

*6:

saveinformationtofile*"

*7:

quitthesystem*"

}

/*添加一个火车信息*/

voidInsertTraininfo(Linklinkhead)

structnode*p,*r,*s;

r=linkhead;

s=linkhead->

next;

while(r->

next!

=NULL)

r=r->

while

(1)

{

printf("

pleaseinputthenumberofthetrain(0-return)"

scanf("

%s"

num);

if(strcmp(num,"

0"

)==0)

break;

/*判断是否已经存在*/

while(s)

if(strcmp(s->

data.num,num)==0)

thetrain'

%s'

hasbeenborn!

\n"

return;

}

s=s->

p=(structnode*)malloc(sizeof(structnode));

strcpy(p->

data.num,num);

Inputthecitywherethetrainwillreach:

"

p->

data.city);

Inputthetimewhichthetraintakeoff:

data.takeoffTime);

Inputthetimewhichthetrainreceive:

&

p->

data.receiveTime);

Inputthepriceofticket:

%d"

data.price);

Inputthenumberofbookedtickets:

data.bookNum);

next=NULL;

r->

next=p;

r=p;

shoudsave=1;

/*打印火车票信息*/

voidprintTrainInfo(structnode*p)

\nThefollowingistherecordyouwant:

>

numberoftrain:

%s\n"

data.num);

citythetrainwillreach:

thetimethetraintakeoff:

%s\nthetimethetrainreach:

data.takeoffTime,p->

thepriceoftheticket:

%d\n"

thenumberofbookedtickets:

structnode*Locate1(Linkl,charfindmess[],charnumorcity[])

Node*r;

if(strcmp(numorcity,"

num"

r=l->

while(r)

if(strcmp(r->

data.num,findmess)==0)

returnr;

elseif(strcmp(numorcity,"

city"

data.city,findmess)==0)

return0;

/*查询火车信息*/

voidQueryTrain(Linkl)

Node*p;

intsel;

charstr1[5],str2[10];

if(!

l->

next)

Thereisnotanyrecord!

Choosetheway:

\n>

1:

accordingtothenumberoftrain;

2:

accordingtothecity:

sel);

if(sel==1)

Inputthethenumberoftrain:

str1);

p=Locate1(l,str1,"

if(p)

printTrainInfo(p);

else

mark1=1;

\nthefilecan'

tbefound!

elseif(sel==2)

Inputthecity:

str2);

p=Locate1(l,str2,"

/*订票子模块*/

voidBookTicket(Linkl,bookManLinkk)

Node*r[10],*p;

charch,dem;

bookMan*v,*h;

inti=0,t=0;

charstr[10],str1[10],str2[10];

v=k;

while(v->

v=v->

Inputthecityyouwanttogo:

"

str);

p=l->

while(p!

if(strcmp(p->

data.city,str)==0)

r[i]=p;

i++;

p=p->

\n\nthenumberofrecordhave%d\n"

i);

for(t=0;

t<

i;

t++)

printTrainInfo(r[t]);

if(i==0)

\n\t\t\tSorry!

Can'

tfindthetrainforyou!

\ndoyouwanttobookit?

<

1/0>

ch);

if(ch==1)

h=(bookMan*)malloc(sizeof(bookMan));

Inputyourname:

str1);

strcpy(h->

data.name,str1);

Inputyourid:

str2);

data.num,str2);

InputyourbookNum:

dem);

h->

data.bookNum=dem;

v->

next=h;

v=h;

\nLucky!

youhavebookedaticket!

getch();

shoudsave=1;

bookMan*Locate2(bookManLinkk,charfindmess[])

bookMan*r;

r=k->

mark=1;

/*修改火车信息*/

voidUpdateInfo(Linkl)

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

当前位置:首页 > 人文社科 > 法律资料

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1