C语言编程火车订票系统源代码Word文档下载推荐.docx

上传人:b****2 文档编号:5333208 上传时间:2023-05-05 格式:DOCX 页数:17 大小:19.51KB
下载 相关 举报
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

structpeople*next;

JbookMan/bookManLink;

/*初始界面*7

voidprintlnterface()

{puts(H********************************************************uputs(H*Welcometousethesystemofbookingtickets*n);

puts(H********************************************************Hputs(H*Youcanchoosetheoperation:

*"

);

puts("

*

l:

lnsertatraininformation

*u);

2:

lnquireatraininformation

*H);

3:

Bookatrainticket

4:

Updatethetraininformation

5:

Advicetoyouaboutthetrain

*n);

6:

saveinformationtofile

7:

quitthesystem

}

厂添加一个火车信息-7

voidlnsertTraininfo(Linklinkhead){

structnode*p,*rz*s;

r=linkhead;

s=linkhead->

next;

while(r->

next!

=NULL)

r=r->

while(l)

printf(Hpleaseinputthenumberofthetrain(O-return)”);

scanf「%s舄num);

讦(strcmp(num,,lO,,)==O)

break;

厂判断是否已经存在-7

while(s)

if(strcmp(s->

data.num,num)==O)

printff'

thetrain%s'

hasbeenborn!

\n舄num);

return;

}s=s・>

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

strcpy(p->

data.num,num);

printf(Hlnputthecitywherethetrainwillreach:

11);

scanf("

%s:

p・>

data.city);

printf(nlnputthetimewhichthetraintakeoff:

"

scanf(,,%s,,,p->

data.takeoffTime);

printf(Mlnputthetimewhichthetrainreceive:

scanfC^s'

^&

p^data.receiveTime);

printf(Mlnputthepriceofticket:

scanf(,,%d,,,&

p->

data.price);

printf(Mlnputthenumberofbookedtickets:

scanf(,,%d,,,&

data.bookNum);

p->

next=NULL;

r->

next=p;

r=P;

shoudsave=1;

厂打印火车票信息>7

voidprintTrainlnfo(structnode*p)

puts(H\nThefollowingistherecordyouwant:

printf(H»

numberoftrain:

%s\nH,p->

data.num);

citythetrainwillreach:

%s\n'

^p^data.city);

printf(u»

thetimethetraintakeoff:

%s\nthetimethetrainreach:

%s\nI,,p->

data.takeoffTime,p->

data.receiveTime);

thepriceoftheticket:

%d\n,,/p->

printf(u»

thenumberofbookedtickets:

%d\n舄podata.bookNum);

structnode*LocatelfLinkl,charfindmess[],charnumorcity[])

Node*r;

if(strcmp(numorcity;

,num,,)==0)

r=l->

while(r)

if(strcmp(r->

data.num,findmess)==O)returnr;

else讦(strcmp(numorcityrcity”)==0)

data.city,findmess)==O)returnr;

return0;

厂查询火车信息沐/

voidQueryTrain(LinkI)

Node*p;

intsei;

charstrl[5],str2[10];

if(!

l->

next)

{printf(HThereisnotanyrecord!

H);

return;

printf("

Choosetheway:

\n>

>

accordingtothenumberoftrain;

\n»

accordingtothecity:

\n"

);

scanf(“%d”,&

sel);

if(sel==l)

lnputthethenumberoftrain:

scanf("

%s"

strl);

p=Locatel(l,strl/,num"

if(P)

printTrainlnfo(p);

else

markl=l;

printf("

\nthefilecan'

tbefound!

else讦(sel==2)

lnputthecity:

scanf("

str2);

p=Locatel(l,str2/"

city"

printf(u\nthefilecan'

/*订票子模块*/

voidBookTicket(Linkl,bookManLinkk)

Node*r[10],*p;

charch,dem;

bookMan*v,*h;

inti=O,t=O;

charstr[10],strl[10],str2[10];

v=k;

while(v->

v=v->

printf(nlnputthecityyouwanttogo:

H);

scanf("

&

str);

p=l->

while(p!

if(strcmp(p->

data.city,str)==O)

r[H=P;

i++;

p=p->

printf(H\n\nthenumberofrecordhave%d\n,,,i);

for(t=0;

t<

i;

t++)

printTrainlnfo(r[t]);

if(i==O)

\n\t\t\tSorry!

Can11findthetrainforyou!

printf(u\ndoyouwanttobookit?

<

l/O>

%d”,&

ch);

讦(ch==1)

h=(bookMan*)malloc⑸zeof(booklVlan));

printf(Hlnputyourname:

&

strl);

strcpy(h->

data.name,strl);

printf(Hlnputyourid:

str2);

data.num,str2);

printf「InputyourbookNum:

%cT,&

dem);

h・>

data.bookNum二dem;

h->

v・>

next=h;

v=h;

printf(H\nLucky!

youhavebookedaticket!

getch();

shoudsave=l;

bookMan*Locate2(bookManLinkk,charfindmess[])

bookMan*r;

r=k->

data.num,finclmess)==O)

mark=l;

returnr;

厂修改火车信息沐/

voidUpdatelnfofLinkI)

Node*p;

charfindmess[20],ch;

printf(u\nthereisn'

trecordforyoutomodify!

\nu);

QueryTrain(l);

if(markl==O)

printf(H\nDoyouwanttomodifyit?

\nH);

getchar();

scanf「%c舄&

if(ch=='

y'

printf(H\nlnputthenumberofthetrain:

scanf(,,%s"

/findmess);

p=Locatel(l,findmess/1num11);

讦(P)

ticket:

printf「Inputnewnumberoftrain:

scanf(,,%s,,,&

printf(Hlnputnewcitythetrainwillreach:

printf(nlnputnewtimethetraintakeoff11);

printf(Hlnputnewtimethetrainreach:

seanf「%s—&

printf(Mlnputnewpriceoftheticket:

:

scanf(,,%d,,/&

printf(Hlnputnewnumberofpeoplewhohavebooked

scanf(,,%d,,/&

printf(H\nmodifyingrecordissucessful!

\nJ;

shoudsave=l;

XtXtXtcan'

tfindtherecord!

markl=O;

/*系统给用户的提示信息*/

voidAdvicedTrains(LinkI)

charstr[10];

intmar=O;

luputthecityyouwanttogo:

n);

scanf「%s舄str);

讦(strcmp(r->

data.city,str)==0&

&

data.bookNum<

200)

mar=l;

printf(H\nyoucanselectthefollowingtrain!

\nM);

\n\npleaseselectthefourthoperationtobooktheticket!

printTrainlnfo(r);

if(mar==O)

printf(H\n\t\t\tyoucan'

tbookanyticketnow!

/*保存火车信息

voidSaveTrainInfo(LinkI)

FILE*fp;

intcount=O,flag二1;

fp=fopen(,,c:

\\train.txt,,/,,wb"

if(fp==NULL)

printf(uthefilecan'

tbeopened!

while(p)

if(fwrite(p,sizeof(Node)/l,fp)==l)

next;

count++;

flag=O;

if(flag)

thenumberoftherecordwhichhavebeensavedis%d\nHzcount);

shoudsave=0;

}fclose(fp);

厂保存订票人的信息*/

voidSaveBookmanInfo(bookManLinkk)

FILE*fp;

bookMan*p;

intcount=O,fbg二1;

fp=fopen「c:

\\man・txtTwb“);

printf(Hthefilecan'

p=k->

if(fwrite(p,sizeof(bookMan),l,fp)==l)

flag=O;

printf(uthenumberoftherecordwhichhavebeensavedis%d\n'

^count);

fclose(fp);

intmain()

FILE*fpl,*fp2;

Node*p,*r;

charchl,ch2;

LinkI;

bookManLinkk;

bookMan*t,*h;

l=(Node*)malloc(sizeof(Node));

l・>

next=NULL;

r=l;

k=(bookMan*)malloc(sizeof(bookl\/lan));

konext=NULL;

h=k;

fpl=fopen(,,c:

\\train.txt,,z,,ab+"

if((fpl==NULL))

can'

topenthefile!

return0;

while(!

feof(fpl))

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

if(fread(p,sizeof(Node)/l,fpl)==l)

countl++;

fclose(fpl);

fp2=fopen("

c:

\\man.txt,,/"

ab+"

if((fp2==NULL))

feof(fp2))

t=(bookMan*)malloc⑸zeof(bookMan));

if(fread(t/sizeof(bookMan),l/fp2)==l){

t・>

h->

next=t;

h=t;

count2++;

fclose(fp2);

systemC'

cls"

printlnterface();

printf(Hpleasechoosetheoperation:

%d“,&

if(sel==8)

讦(shoudsave==l)

getchar();

printf(u\nthefilehavebeenchangedidoyouwanttosaveit(y/n)?

%比&

chl);

if(chl=='

||chl=='

Y'

SaveBookmanlnfo(k);

SaveTrainlnfo(l);

printf(H\nThankyou!

!

Youarewelcometoo\n”);

break;

switch(sel)

case1:

InsertTraininfo(l);

case2:

case3:

BookTicket(I,k);

case4:

Updatelnfo(l);

case5:

AdvicedTrains(l);

case6:

case7:

printf(H\npleasepressanykeytocontinue"

getch();

}

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

当前位置:首页 > 初中教育 > 语文

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

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