注册 登录
编程论坛 数据结构与算法

飞机订票系统(数组做法)

风之舞者 发布于 2006-07-09 09:47, 7546 次点击

本人这学期的课程设计题目 发到网上来大家帮帮看看 哪里做的还不够好 希望大家能给我留下宝贵的意见呵呵
非常谢谢 当然本人这也有报告 想要的话也是用邮箱吧 看着别人发帖子我心里也痒痒了

代码:501行

# include"stdio.h"
# include"string.h"
# include"stdlib.h"
# define N 100

char sel1;
char sel2;
int fm=0;
int pm=0;

struct flight
{int flightnum;
int starttime;
int arrivedtime;
char start[10];
char arrived[10];
int portermax;
int money;
int flytime;
char date[10];
}s[N];

struct porter
{char name[10];
char unit[10];
int licencenum;
int ticketdate;
int flightnum;
int sizenum;
}a[N];

void input()
{int i=0;
int num;
int k;
scanf("%d",&num);
while(num==1)
{printf("Please input the new flightnumber:");
scanf("%d",&s[i].flightnum);
printf("Please input the starttime:");
scanf("%d",&s[i].starttime);
printf("Please input the arrivedtime:");
scanf("%d",&s[i].arrivedtime);
printf("Please input the start:");
scanf("%s",s[i].start);
printf("Please input the arrived:");
scanf("%s",s[i].arrived);
printf("Please input the portermax:");
scanf("%d",&s[i].portermax);
printf("Please input the money:");
scanf("%d",&s[i].money);
printf("Please input the flytime:");
scanf("%d",&s[i].flytime);
printf("please input the date");
scanf("%s",s[i].date);
i++;
printf("need to creade another new flight? yes=1 no=other.");
scanf("%d",&num);
};
fm=i;
printf("Return to main menu?(Yes=1)");
scanf("%d",&k);
if (k==1)
main();
}

void findflight()
{ int i;
int j;
int k;
char st[10];
char ar[10];
int sn;
printf("Please input the start:");
scanf("%s",st);
printf("Please input the arrived:");
scanf("%s",ar);
printf(" fltnum start arrived starttime arrtime max money flt date\n");
sn=0;
for(i=0;i<=fm;i++)
{if ((strcmp(st,s[i].start)==0)&&(strcmp(ar,s[i].arrived)==0))
{printf("%7d%10s%10s%10d%10d%5d%6d%4d%5s\n",s[i].flightnum,s[i].start,s[i].arrived,
s[i].starttime,s[i].arrivedtime,s[i].portermax,s[i].money,s[i].flytime,s[i].date);
sn=1;s[i].portermax--;}}
if (sn==0)
{printf("the flight you need is not found!please check it!\n");
printf("Return to main menu?(Yes=1)");
scanf("%d",&k);
if (k==1)
main();}
printf("Please input the name:");
scanf("%s",a[pm].name);
printf("Please input the unit:");
scanf("%s",a[pm].unit);
printf("Please input the licencenum:");
scanf("%d",&a[pm].licencenum);
printf("Please input the ticketdate:");
scanf("%d",&a[pm].ticketdate);
printf("Please input the flightnum:");
scanf("%d",&a[pm].flightnum);
printf("Please input the sizenum:");
scanf("%d",&a[pm].sizenum);
pm=pm+1;
printf("Return to main menu?(Yes=1)");
scanf("%d",&k);
if (k==1)
main();
}
void passticket()
{int i;
int ptfn;
int ptsn;
int dm;
int yn;
int k;
printf("please input the flight num:");
scanf("%d",&ptfn);
printf("please input the size num:");
scanf("%d",&ptsn);
for (i=0;i<=fm;i++)
{if ((s[i].flightnum==ptfn)&&(a[i].sizenum==ptsn))
{dm=i;
s[i].portermax++;
printf("please back the money!\n");}}

printf("would you like to pass the porter?");
printf("yes=1,no=2");
scanf("%d",&yn);
if (yn==1)
{int j;


for (j=dm;j<=pm;j++)
{a[j]=a[j+1];
}
pm=pm-1;
printf("\nthe porter has been delete!\n");}
printf("Return to main menu?(Yes=1)");
scanf("%d",&k);
if (k==1)
main();
}

void findflightzl()
{int fln;
int i;
int j;
printf("please input the flightnum you want to find:");
scanf("%d",&fln);
printf(" fltnum start arrived starttime arrtime max money flt date\n");
for (i=0;i<=pm;i++)
{if (s[i].flightnum==fln)
printf("%7d%10s%10s%10d%10d%5d%6d%4d%5s\n",s[i].flightnum,s[i].start,s[i].arrived,
s[i].starttime,s[i].arrivedtime,s[i].portermax,s[i].money,s[i].flytime,s[i].date);
}
printf("Return to main menu?(Yes=1)");
scanf("%d",&j);
if (j==1)
main();
}

void findbydate()
{char da[10];
int i;
int j;
printf("please input the date you want to find:");
scanf("%s",&da);
printf(" fltnum start arrived starttime arrtime max money flt date\n");
for (i=0;i<=pm;i++)
{if (strcmp(s[i].date,da)==0)
printf("%7d%10s%10s%10d%10d%5d%6d%4d%5s\n",s[i].flightnum,s[i].start,s[i].arrived,
s[i].starttime,s[i].arrivedtime,s[i].portermax,s[i].money,s[i].flytime,s[i].date);
}
printf("Return to main menu?(Yes=1)");
scanf("%d",&j);
if (j==1)
main();
}

void mainmenu();

void newflight()
{ int i=fm;
int k;
printf("Please input the new flightnumber:");
scanf("%d",&s[i].flightnum);
printf("Please input the starttime:");
scanf("%d",&s[i].starttime);
printf("Please input the arrivedtime:");
scanf("%d",&s[i].arrivedtime);
printf("Please input the start:");
scanf("%s",s[i].start);
printf("Please input the arrived:");
scanf("%s",s[i].arrived);
printf("Please input the portermax:");
scanf("%d",&s[i].portermax);
printf("Please input the money:");
scanf("%d",&s[i].money);
printf("Please input the flytime:");
scanf("%d",&s[i].flytime);
printf("please input the date:");
scanf("%s",s[i].date);
fm=fm+1;
printf("Return to main menu?(Yes=1)");
scanf("%d",&k);
if (k==1)
main();
}

void passflight()
{int pfn;
int tm;
int yn;
int i;
int k;
printf("please input the flightnum you need:");
scanf("%d",&pfn);
for (i=0;i<=fm;i++)
{if (s[i].flightnum==pfn)
tm=i;}
printf("would you like to pass the flight?");
printf("yes=1,no=2");
scanf("%d",&yn);
if (yn==1)
{int j;
for (j=tm;j<=fm;j++)
{s[j]=s[j+1];}
fm=fm-1;
printf("the flight has been delete!\n");}
printf("Return to main menu?(Yes=1)");
scanf("%d",&k);
if (k==1)
main();
}
void findflightname()
{
int i;
int j;
char name[10];
printf("please input the name you want to find:");
scanf("%s",name);
printf(" name unit licnum ticdat flinum siznum\n");
for (i=0;i<=pm;i++)
{if (strcmp(a[i].name,name)==0)
printf("%10s%10s%10d%10d%10d%10d\n",a[i].name,a[i].unit,a[i].licencenum,a[i].ticketdate,
a[i].flightnum,a[i].sizenum);}
printf("Return to main menu?(Yes=1)");
scanf("%d",&j);
if (j==1)
main();
}
void find_start_arrived()
{
int i;
int j;
char st[10];
char ar[10];
printf("Please input the start:");
scanf("%s",st);
printf("Please input the arrived:");
scanf("%s",ar);
printf(" fltnum start arrived starttime arrtime max money flt date\n");
for(i=0;i<=fm;i++)
{if ((strcmp(st,s[i].start)==0)&&(strcmp(ar,s[i].arrived)==0))
printf("%7d%10s%10s%10d%10d%5d%6d%4d%5s\n",s[i].flightnum,s[i].start,s[i].arrived,
s[i].starttime,s[i].arrivedtime,s[i].portermax,s[i].money,s[i].flytime,s[i].date);}
printf("Return to main menu?(Yes=1)");
scanf("%d",&j);
if (j==1)
main();
}
void flightmanage();
void findbydate();
void findfly()
{
char find;
system("cls");
printf("\n");
printf("\n");
printf(" **********************************************************************\n");
printf(" * *\n");
printf(" * Flight find *\n");
printf(" * *\n");
printf(" **********************************************************************\n");
printf("\n");
printf("\n");
printf("\n");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf(" + +\n");
printf(" + Please choose: (input the serial number) +\n");
printf(" + +\n");
printf(" + +\n");
printf(" + 1. Find by flightnum. +\n");
printf(" + +\n");
printf(" + 2. Find by portername. +\n");
printf(" + +\n");
printf(" + 3. Find by datenum. +\n");
printf(" + +\n");
printf(" + 4. Find by start-arrived. +\n");
printf(" + +\n");
printf(" + 5. Return to the mainmenu. +\n");
printf(" + +\n");
printf(" + +\n");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf("please select:");
scanf("%c",&find);
switch(find)
{
case '1' : findflightzl();break;
case '2' : findflightname();break;
case '3' : findbydate();break;
case '4' : find_start_arrived();break;
case '5' : main();break;
default : break;
}

}

void flightmanage();

void dayflightmanage()
{
int i;
int j;
char day[10];
printf("Please input date:");
scanf("%s",day);
printf(" fltnum start arrived starttime arrtime max money flt date\n");
for(i=0;i<=fm;i++)
{if (strcmp(day,s[i].date)==0)
printf("%7d%10s%10s%10d%10d%5d%6d%4d%5s\n",s[i].flightnum,s[i].start,s[i].arrived,s[i].starttime,s[i].arrivedtime,s[i].portermax,s[i].money,s[i].flytime,s[i].date);
}
printf("Return to main menu?(Yes=1) Return to flightmanage menu?(No=0)");
scanf("%d",&j);
if (j==1)
main();
else
flightmanage();

}

void recentmanage()
{
char stdate[10];
int cha=0;
int i;
int j;
int check=0;
printf("please input startdate:");
scanf("%s",stdate);
printf("\n");
printf(" fltnum start arrived starttime arrtime max money flt date\n");
for(i=0;i<=fm;i++)
if (strcmp(stdate,s[i].date)==0)
{printf("%7d%10s%10s%10d%10d%5d%6d%4d%5s\n",s[i].flightnum,s[i].start,s[i].arrived,
s[i].starttime,s[i].arrivedtime,s[i].portermax,s[i].money,s[i].flytime,s[i].date);
cha=i+1;
check=1;
for(i=cha;i<fm;i++)
{printf("%7d%10s%10s%10d%10d%5d%6d%4d%5s\n",s[i].flightnum,s[i].start,s[i].arrived,
s[i].starttime,s[i].arrivedtime,s[i].portermax,s[i].money,s[i].flytime,s[i].date); }
}
if (check==0)
{printf("can't find any flight!\n");}
printf("Return to main menu?(Yes=1)");
scanf("%d",&j);
if (j==1)
main();
}

28 回复
#2
风之舞者2006-07-09 09:47

void mainmenu()
{

system("cls");
printf("\n");
printf("\n");
printf(" **********************************************************************\n");
printf(" * *\n");
printf(" * Welcome to use the system *\n");
printf(" * *\n");
printf(" **********************************************************************\n");
printf("\n");
printf("\n");
printf("\n");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf(" + +\n");
printf(" + Please choose: (input the serial number) +\n");
printf(" + +\n");
printf(" + +\n");
printf(" + 1. Book ticket(s). +\n");
printf(" + +\n");
printf(" + 2. Return a ticket. +\n");
printf(" + +\n");
printf(" + 3. Scheduled flight manage. +\n");
printf(" + +\n");
printf(" + 4. Get information. +\n");
printf(" + +\n");
printf(" + 5. Save and exit. +\n");
printf(" + +\n");
printf(" + +\n");
printf(" + +\n");
printf(" + +\n");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf("\n");
printf("\n");
printf("\n");
printf("please select:");
scanf("%c",&sel1);
}

void mainmenu();
void dayflightmanage();
void findflightzl();
void passflight();
void flightmanage()
{

system("cls");
printf("\n");
printf("\n");
printf(" **********************************************************************\n");
printf(" * *\n");
printf(" * Flight manage menu *\n");
printf(" * *\n");
printf(" **********************************************************************\n");
printf("\n");
printf("\n");
printf("\n");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf(" + +\n");
printf(" + Please choose: (input the serial number) +\n");
printf(" + +\n");
printf(" + +\n");
printf(" + 1. Get base information of Scheduled flight. +\n");
printf(" + +\n");
printf(" + 2. Day fly condition manage. +\n");
printf(" + +\n");
printf(" + 3. Recent fly condition manage. +\n");
printf(" + +\n");
printf(" + 4. insert new flight. +\n");
printf(" + +\n");
printf(" + 5. Delete flight. +\n");
printf(" + +\n");
printf(" + 6. Return main menu. +\n");
printf(" + +\n");
printf(" + +\n");
printf(" + +\n");
printf(" ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++\n");
printf("\n");
printf("\n");
printf("\n");
printf("please select:");
scanf("%c",&sel2);
switch (sel2)
{
case '1' : findflightzl();break;
case '2' : dayflightmanage();break;
case '3' : recentmanage();break;
case '4' : newflight();break;
case '5' : passflight();break;
case '6' : mainmenu();break;
default : break;
}
}

void filesave()
{int j;
FILE *fp;
if((fp=fopen("flight","wb"))==NULL)
{printf("can't open file!\n");
return;
}
for(j=0;j<fm;j++)
if(fwrite(&s[j],sizeof(struct flight),1,fp)!=1)
printf("file write error!\n");
fclose(fp);
exit(1);
}

main()
{

mainmenu();
switch (sel1)
{
case '1' : findflight();break;
case '2' : passticket();break;
case '3' : flightmanage();break;
case '4' : findfly();break;
case '5' : filesave();break;
default : break;

}
}

#3
tanyongqing2006-07-12 19:15
[求助] 飞机票系统

麻烦给我发下报告,谢谢~

#4
tanyongqing2006-07-13 23:18

我也想要报告,谢谢,麻烦发到tan921520@163.com

#5
风之舞者2006-07-16 01:48

好的  ==啊

#6
jianhen2006-07-17 14:09

你系统里的错误输入处理还有待改进,这是我个人的意见。
如果可以的话,也请你发一份报告给我吧,我的邮箱是fmj3312@163.com。谢谢!

#7
jianhen2006-07-17 14:11
还有就是你的Welcome to use the system这个都没有显示出来,
#8
风之舞者2006-07-18 03:36
其实这个系统还是有几个错误和BUG的  还有待改进  我已经给你邮箱发过去了  有什么能够帮我改正的还请多多指教  谢谢
#9
cky10142006-08-08 09:49
我也想看看报告参考呢,谢谢~~~
chenrainy@sina.com
#10
风之舞者2006-08-23 01:51

没啥好参考的 随便做了一个 运行起来还可以 你要是愿意看报告的话以后有机会的吧 我在外地 没办法给你报告 不好意思

#11
a4140653102006-09-07 10:11
我要报告啊,马上要交作业了,帮帮忙啊.大哥.
zhang_peng18@163.com
谢谢了!
#12
xzh5109592006-09-07 13:35
我也想要报告,谢谢你哦……我的邮箱是——490912518@sohu.com
#13
风之舞者2006-09-07 20:18
现在报告没了  你看着怎么弄自己做一个吧  挺简单的
#14
h_nelson2007-07-02 19:36

请问用什么环境编译的?TC?
请大概说说用了哪些数据结构和算法?
初学者恳请赐教,谢谢!

#15
a328534042007-07-03 15:45

我也要报告,邮箱是32853404@163.com
谢拉

#16
bluekissok2007-07-17 14:03
回复:(风之舞者)飞机订票系统(数组做法)
哥们好啊
现在正在做这个 能不能给我发一个啊 谢谢咯
邮箱 qianjun200888@163.com
#17
dyjazw2007-07-21 21:54
大家瞧瞧我的:
#include<iostream.h>
#include<stdio.h>
#include<windows.h>
int count=0;
const MAX=10;
//#include<afxwin.h>
//航班时间
typedef struct
{
int year;
int month;
int day;
int hour;
int minute;
}Time;

//航班信息
typedef struct
{
int num; //航班号
Time time[2];//起降时间
char elem[10];//抵达城市
// char * elem;
int price;//航班票价
float f;//票价折扣
int b;//是否仓满 “1”为满 “0”未满
}PLANE[MAX],SKY;

typedef struct ALL
{
PLANE plane;
int count;
}ALL;

//定票信息
typedef struct PP
{
char name[10];//客户姓名
int ID;//客户ID
int num;//定票数量
SKY plane;//航班情况
//int data;//定单编号
struct PP *next;
}*PASSEGER,PS;

void Input_Plane(ALL &all)
{
//char a[10];
//int n;
bool bb=1;
char c;
for(int i=1;i<=10&&bb;i++)
{
all.count++ ;
cout<<"请输入航班信息:\n";
cout<<"航班号:";
cin>>all.plane[all.count].num;
cout<<"航班票价:";
cin>>all.plane[all.count].price;
cout<<"票价折扣:";
cin>>all.plane[all.count].f;
cout<<"是否仓满:(1为仓满,0为未满)";
cin>>all.plane[all.count].b;
cout<<"起飞时间:";
cin>>all.plane[all.count].time[0].year>>all.plane[all.count].time[0].month>>all.plane[all.count].time[0].day>>all.plane[all.count].time[0].hour>>all.plane[all.count].time[0].minute;
cout<<"降落时间:";
cin>>all.plane[all.count].time[1].year>>all.plane[all.count].time[1].month>>all.plane[all.count].time[1].day>>all.plane[all.count].time[1].hour>>all.plane[all.count].time[1].minute;
cout<<"抵达城市:";
for(int i=0;i<10;i++)
{
cin>>all.plane[all.count].elem[i];
if(all.plane[all.count].elem[i]=='#')
break;
}
cout<<"是否继续录入?(Y/N)";
cin>>c;
if(c=='Y')
bb=1;
else
bb=0;
}
}
void Search(ALL all)
{
int haoma;
int j=0;
cout<<"请输入航班号:";
cin>>haoma;
while(all.plane[j].num!=haoma&&j<10)
j++;
if(all.plane[j].num!=haoma)
cout<<"无此航班!";
else
{
cout<<"您所要查询的航班情况如下:\n";
cout<<"航班票价:";
cout<<all.plane[j].price<<'\n';
cout<<"票价折扣:";
cout<<all.plane[j].f<<'\n';
cout<<"是否仓满:";
if(all.plane[j].b==1)
cout<<"仓满"<<'\n';
else
cout<<"未满"<<'\n';
cout<<"起飞时间:";
cout<<all.plane[j].time[0].year<<"年"<<all.plane[j].time[0].month<<"月"<<all.plane[j].time[0].day<<"日"<<all.plane[j].time[0].hour<<"时"<<all.plane[j].time[0].minute<<"分"<<'\n';
cout<<"降落时间:";
cout<<all.plane[j].time[1].year<<"年"<<all.plane[j].time[1].month<<"月"<<all.plane[j].time[1].day<<"日"<<all.plane[j].time[1].hour<<"时"<<all.plane[j].time[1].minute<<"分"<<'\n';
cout<<"抵达城市:";
for(int i=0;i<10;i++)
{
cout<<all.plane[j].elem[i];
if(all.plane[j].elem[i+1]=='#')
break;
}
}
cout<<'\n';
}
void Modify(ALL &all)
{
int num;
int j=0;
bool bb=1;
char c;
while(bb)
{
cout<<"请输入所要修改航班的航班号:";
cin>>num;
while(all.plane[j].num!=num&&j<10)
j++;
if(all.plane[j].num!=num)
cout<<"无此航班!";
else
{
cout<<"您所要查询的航班情况如下:\n";
cout<<"航班票价:";
cout<<all.plane[j].price<<'\n';
cout<<"票价折扣:";
cout<<all.plane[j].f<<'\n';
cout<<"是否仓满:";
if(all.plane[j].b==1)
cout<<"仓满"<<'\n';
else
cout<<"未满"<<'\n';
cout<<"起飞时间:";
cout<<all.plane[j].time[0].year<<"年"<<all.plane[j].time[0].month<<"月"<<all.plane[j].time[0].day<<"日"<<all.plane[j].time[0].hour<<"时"<<all.plane[j].time[0].minute<<"分"<<'\n';
cout<<"降落时间:";
cout<<all.plane[j].time[1].year<<"年"<<all.plane[j].time[1].month<<"月"<<all.plane[j].time[1].day<<"日"<<all.plane[j].time[1].hour<<"时"<<all.plane[j].time[1].minute<<"分"<<'\n';
cout<<"抵达城市:";
for(int i=0;i<10;i++)
{
cout<<all.plane[j].elem[i];
if(all.plane[j].elem[i+1]=='#')
break;
}
cout<<'\n';
cout<<"航班票价:";
cin>>all.plane[j].price;
cout<<"票价折扣:";
cin>>all.plane[j].f;
cout<<"是否仓满:(1为仓满,0为未满)";
cin>>all.plane[j].b;
cout<<"起飞时间:";
cin>>all.plane[j].time[0].year>>all.plane[j].time[0].month>>all.plane[j].time[0].day>>all.plane[j].time[0].hour>>all.plane[j].time[0].minute;
cout<<"降落时间:";
cin>>all.plane[j].time[1].year>>all.plane[j].time[1].month>>all.plane[j].time[1].day>>all.plane[j].time[1].hour>>all.plane[j].time[1].minute;
cout<<"抵达城市:";
for(i=0;i<10;i++)
{
cin>>all.plane[j].elem[i];
if(all.plane[j].elem[i]=='#')
break;
}
cout<<"是否继续修改?(Y/N)";
cin>>c;
if(c=='Y')
bb=1;
else
bb=0;
}
}
}

void D_Ticket(PASSEGER passeger,ALL &all)
{
bool bb,B,cc=0;
char elem[10];
int num;
PASSEGER p,s;
cout<<"请输入您要前往的地点 :";
for(int i=0;i<10;i++)
{
cin>>elem[i];
if(elem[i]=='#')
break;
}
for(int j=0;j<=all.count;j++)
{
bb=1;
for(i=0;i<10;i++)
{
if(all.plane[j].elem[i]!=elem[i])
{
bb=0;
break;
}
else
bb=1;
}
if(bb)
{
cc=1;
cout<<"您所要查询的地点的信息为:\n";
cout<<"航班号:";
cout<<all.plane[j].num<<'\n';
cout<<"航班票价:";
cout<<all.plane[j].price<<'\n';
cout<<"票价折扣:";
cout<<all.plane[j].f<<'\n';
cout<<"是否仓满:";
if(all.plane[j].b==1)
cout<<"仓满"<<'\n';
else
cout<<"未满"<<'\n';
cout<<"起飞时间:";
cout<<all.plane[j].time[0].year<<"年"<<all.plane[j].time[0].month<<"月"<<all.plane[j].time[0].day<<"日"<<all.plane[j].time[0].hour<<"时"<<all.plane[j].time[0].minute<<"分"<<'\n';
cout<<"降落时间:";
cout<<all.plane[j].time[1].year<<"年"<<all.plane[j].time[1].month<<"月"<<all.plane[j].time[1].day<<"日"<<all.plane[j].time[1].hour<<"时"<<all.plane[j].time[1].minute<<"分"<<'\n';
}
}
if(cc)
{
B=1;
while(B)
{
cout<<"请输入您要定票的航班号:";
cin>>num;
j=0;
while(all.plane[j].num!=num)
j++;
if(all.plane[j].b==1)
cout<<"该机已满,请您重新选择航班!\n";
else
B=0;
}
p=passeger;
while(p->next)
p=p->next;
count++;
s=new PS;
cout<<"请输入姓名:";
for(i=0;i<10;i++)
{
cin>>s->name[i];
if(s->name[i]=='#')
break;
}
cout<<"请输入ID:";
cin>>s->ID;
cout<<"请输入定票的数量:";
cin>>s->num;
s->plane.num=num;
p->next=s;
s->next=NULL;
}
else
cout<<"无通往该地点的航班!";
}
void T_Ticket(PASSEGER passeger)
{
int a;
PASSEGER p,q;
bool bb=1;
cout<<"请输入ID:";
cin>>a;
q=p=passeger;
while(p)
{
if(p->ID==a)
{
bb=0;
break;
}
else
{
q=p;
p=p->next;
}
}
if(bb)
cout<<"该用户无定票情况!\n";
else
{
if(p->next==NULL)
q->next=NULL;
else
{
q->next=p->next;
free(p);
}
count--;
cout<<"退票成功!";
}
}
void save_Plane(ALL &all)
{
FILE *fp;
fp=fopen("plane","w");
fwrite(&all,sizeof(struct ALL),1,fp);
fclose(fp);
}
void save_People(PASSEGER passeger,ALL &all)
{
FILE *fp;
PASSEGER p;
p=passeger->next;
fp=fopen("passeger","w");
fwrite(&count,sizeof(int),1,fp);
while(p)
{
fwrite(p,sizeof(struct PP),1,fp);
p=p->next;
}
fclose(fp);
}
void load_Plane(ALL &all)
{
FILE *fp;
if((fp=fopen("plane","r"))==NULL)
cout<<"Can not open the file plane!\n";
else{
fread(&all,sizeof(struct ALL),1,fp);
fclose(fp);
}
}
void load_People(PASSEGER passeger,ALL &all)
{
FILE *fp;
PASSEGER p,s;
int a;
if((fp=fopen("passeger","r"))==NULL)
{
cout<<"Can not open the file passeger!\n";

}
else
{
p=passeger;
fread(&count,sizeof(int),1,fp);
a=count;
while(count)
{
s=new PS;
fread(s,sizeof(struct PP),1,fp);
p->next=s;
p=s;
count--;
}
count=a;
p->next=NULL;
fclose(fp);
}
}
void Search_People(PASSEGER passeger,ALL &all)
{
PASSEGER p;
bool bb=1;
int num;
cout<<"请输入ID:";
cin>>num;
p=passeger;
while(p)
{
if(p->ID==num)
{
bb=0;
break;
}
p=p->next;
}
if(bb)
cout<<"该用户无定票情况!\n";
else
{
cout<<"姓名:";
for(int i=0;i<10;i++)
{
cout<<p->name[i];
if(p->name[i+1]=='#')
break;
}
cout<<'\n';
cout<<"定票数量:"<<p->num<<'\n';
cout<<"所定航班号:"<<p->plane.num<<'\n';
}
}


void main()
{
ALL all;
PASSEGER passeger;
passeger=new PS;
passeger->next=NULL;
all.count=0;
bool b;
int a;
char c;
b=1;
load_Plane(all);
load_People(passeger,all);
while(b)
{
cout<<"********************************************\n";
cout<<" 1.录入 2.查询 3.定票 \n";
cout<<" 4.退票 5.修改 6.查询定票纪录\n";
cout<<"********************************************\n";
cout<<"请选择:";
cin>>a;
switch (a)
{
case 1:Input_Plane(all);break;
case 2:Search(all);break;
case 3:D_Ticket(passeger,all);break;
case 4:T_Ticket(passeger);break;
case 5:Modify(all);break;
case 6:Search_People(passeger,all);break;
}
cout<<"是否继续?(Y/N)";
cin>>c;
if(c=='Y')
b=1;
else
{
b=0;
save_Plane(all);
save_People(passeger,all);
exit(0);
}
}
}

#18
dyjazw2007-07-21 21:58
我还是一学生,这是我在学校的作业,有什么要改进的地方,大家指导一下啊
#19
卷入内核2007-07-23 00:56
现在的学生怎么写个简单的程序也来网上找
#20
wingyip2007-07-24 08:13
#21
wingyip2007-07-27 10:00
天啊 你手癢就寫了這么長的程序啊
xo9287@sina.com 謝謝啦
#22
john_19882007-09-08 23:27
这个程序修改好了没呢?
#23
longfeng8672007-10-04 01:07
哥们啊,看一段程序最怕的就是没有注释,你可做的真是到位啊
#24
dxq5306102862007-10-06 12:13
要是有注释就好了
#25
sasasa32008-01-11 15:46
实在太感谢楼主了,请楼主帮帮小弟,把你的实验报告发到邮箱 [email]sasasa3@[/email] 。还有,希望楼主所给的程序最好能够有中文解析之
#26
HaPpY随心2008-01-16 08:04
回复 2# 的帖子
谢谢LZ,我的邮箱[email]ren0522@[/email]
#27
javaleo2008-01-19 12:46
回复 19# 的帖子
你忘了你刚学的时候是什么样的了吧?
#28
fji072008-06-30 15:54
我正需要这个系统参考  非常感谢!!492141331@
#29
YYX小子2014-12-29 13:23
楼主,不知你的报告还在不在?我也想要看看!
1