![](/uploads/image/0169.jpg)
#inclu de<st dio.h>
#in clude<stdl ib.h>
#inc lude<mallo c.h>
#incl ude<s tring.h>
t ypede f str uct
{
int mon;
int day;
本溪旅游攻略自由行int hour;
in t min t;
}T ime;
三亚包吃住一体公寓typed ef st ructPassa gerin fo
{
char name[12];
cha r ID[20];
intseatN o;
}P assag erinf o;
ty pedef stru ct Fl ighti nfo
{
cha r cit y1[12];
c har f light num[10];
charplane num[10];
Timesetou t;
T ime a rrive;
fl oat p rice;
flo at di sc;
int t otals eat;
intlefts eat;
intlefts eat0;//真实的剩余位置(退票之后的)Pas sager info*Psli st; Flig htinf o *ne xt;
}Fligh tinfo;
typ edefstruc t Pas sager infor m
{
charname[12];
char ID[20];
int s eatNo;
Fl ighti nfo *fligh t;
}P assag erinf orm;
typed ef st ructDesti natio n
{
charcity[12];
Flig htinf o *Li st;
Desti natio n *ne xt;
}Desti natio n;
Fl ighti nfo *inser tflig ht(Fl ighti nfo *head,charcity[12])
Fl ighti nfo *p0,*p1,*p2;
p1=head;
p0=(Fl ighti nfo *)mall oc(si zeof(Fligh tinfo));
s canf("%s",&p0->fligh tnum);
if(head==NUL L)
{head=p0;p0->ne xt=NU LL; }
els e
{
whi le(st rcmp(p0->f light num,p1->fl ightn um)!=0&&p1->nex t!=NU LL) { p2=p1;p1=p1->next; }
if(s trcmp(p0->fligh tnum,p1->f light num)==0)
{
prin tf("该航班已存在。\n");
retur n(hea d);
}
else
{
p1->ne xt=p0;
p0->next=NULL;
}
}
s trcpy(p0->city1,city); //弥补城市
p rintf(" 飞机号:");
sc anf("%s",&p0->p lanen um);
prin tf("出发时间(月/日/时/分):"); sc anf("%d/%d/%d/%d",&p0->se tout.mon,&p0->s etout.day,&p0-
>setou t.hou r,&p0->set out.m int);
pri ntf("抵达时间(月/日/时/分):"); s canf("%d/%d/%d/%d",&p0->a rrive.mon,&p0->arriv e.day,&p0-
>arri ve.ho ur,&p0->ar rive.mint);
sca nf("%f",&p0->pr ice);
pri ntf("折扣:");
sca nf("%f",&p0->di sc);
prin tf("总位置:");
scanf("%d",&p0->tota lseat);
p0->le ftsea t=p0->tota lseat;
p0->lef tseat0=p0->tota lseat;
p0->Psl ist=(Passa gerin fo *)mallo c((p0->tot alsea t)*si zeof(Passa gerin fo));
ret urn(h ead);
}
in t Qui tnum=0;
De stina tion*inse rtdes t(Des tinat ion *head)
Des tinat ion *p0,*p1,*p2;
p0=(Des tinat ion *)mall oc(si zeof(Desti natio n));
prin tf("抵达城市:");
s canf("%s",&p0->city);
p1=head;
if(head==NUL L)
{
h ead=p0;
p0->L ist=i nsert fligh t(NUL L,p0->city);
p0->n ext=N ULL;
ret urn(h ead);
}
els e
{
whi le(st rcmp(p0->c ity,p1->ci ty)!=0&&p1->nex t!=NU LL)
{ p2=p1;p1=p1->next; }
if(s trcmp(p0->city,p1->c ity)==0)
{
p1->List=inser tflig ht(p1->Lis t,p0->city);
}
e lse
{
p1->next=p0;
深圳大梅沙海滨公园p0->List=inse rtfli ght(N ULL,p0->ci ty);
p0->nex t=NUL L;
}
}
retu rn(he ad);
}
vo id pr intfl ight(Fligh tinfo *q)
{
pr intf("%-10s",q->city1);
print f(" %-10s%-10s",q->fligh tnum,q->pl anenu m);
print f("%2d月%2d号,%2d:%2d ",q->se tout.mon,q->set out.d ay,q-
>seto ut.ho ur,q->seto ut.mi nt);
prin tf("%2d月%2d号,%2d:%2d",q->a rrive.mon,q->ar rive.day,q-
>arr ive.h our,q->arr ive.m int);
pri ntf("%-8.1f %-8.1f %-6d %d\n",q->price,q->d isc,q->tot alsea t,q->lefts eat0); }
v oid p rint(Desti natio n *he ad)
{
Des tinat ion *p;
F light info*q;
p=hea d;
if(!p)prin tf("抱歉,暂无任何航班。\n");
else prin tf("抵达城市航班号飞机号出发时间抵达时间票价/元票价折扣总位置剩余位置\n");
whi le(p)
{
q=p->List;
w hile(q)
{
pri ntfli ght(q);
q=q->next;
}
p=p->ne xt;
}
}
Desti natio n *cr eat(D estin ation *hea d)
{
inti,Fli gtnum;
sc anf("%d",&Fligt num);
fo r(i=0;i<Fl igtnu m;i++)
h ead=i nsert dest(head);
re turn(head);
}
i nt Li stlen gth=800;
P assag erinf orm *passa gerso rt(Pa ssage rinfo rm *h ead,P assag erinf orm *pa,in t n)
{
in t i,j;
if(n>=L istle ngth)
{
head=(Pas sager infor m
*)r eallo c(hea d,(Li stlen gth+100)*s izeof(Pass ageri nform));
List lengt h=Lis tleng th+100;
乌镇要买门票吗}
Pas sager infor m *p;
p=h ead;
if(n==0)
{
strcp y(p->name,pa->n ame);
st rcpy(p->ID,pa->ID);
p->seatN o=pa->seat No;
p->f light=pa->fligh t;
}
els e
{
珠海海泉湾温泉门票价格for(i=0;i<n&&strcm p(pa->ID,(p+i)->ID)>=0;i++);
if(i==n)
{
st rcpy((p+n)->nam e,pa->name);
strc py((p+n)->ID,pa->ID);
(p+n)->sea tNo=p a->se atNo;
(p+n)->flig ht=pa->fli ght;
}
else
{
fo r(j=n;j>i;j--)
{
s trcpy((p+j)->na me,(p+j-1)->nam e);
st rcpy((p+j)->ID,(p+j-1)->I D);
(p+j)->seatN o=(p+j-1)->seat No;
(p+j)->fligh t=(p+j-1)->flig ht;
}
str cpy((p+i)->name,pa->name);
strcp y((p+i)->I D,pa->ID);
(p+i)->seat No=pa->sea tNo;
(p+i)->fligh t=pa->flig ht;
}
}
r eturn(head);
}
Passa gerin fo *o rder_reg(P assag erinf o *Ps list,int n)
{
charname[10],I D[20];
Pa ssage rinfo *p;
prin tf("客户姓名:");
s canf("%s",&name);
p rintf("客户I D:");
sca nf("%s",&I D);
p=Psl ist;
strc py((p+n)->name,name);
st rcpy((p+n)->ID,ID);
(p+n)->se atNo=n+1;
retu rn(Ps list);
}北京的大学排名
v oid p rintp as(Pa ssage rinfo rm *h ead,i nt n)
{
P assag erinf orm *p;
p=head;
pr intf("姓名身份证号航班号飞机号座位号\n");
for(i nt i=0;i<n;i++,p++)
pri ntf("%-10s%-22s%-9s%-10s0%d\n",p->n ame,p->ID,p->se atNo,p->fl ight->flig htnum,p->f light->pla nenum);
}
intprint passa ger(P assag erinf o *Ps list,int n)
{