| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 7536 人关注过本帖, 1 人收藏
标题:飞机订票系统(数组做法)
只看楼主 加入收藏
a414065310
Rank: 1
等 级:新手上路
帖 子:3
专家分:0
注 册:2006-9-7
收藏
得分:0 
我要报告啊,马上要交作业了,帮帮忙啊.大哥.
zhang_peng18@163.com
谢谢了!
2006-09-07 10:11
xzh510959
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2006-9-7
收藏
得分:0 
我也想要报告,谢谢你哦……我的邮箱是——490912518@sohu.com
2006-09-07 13:35
风之舞者
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2006-2-26
收藏
得分:0 
现在报告没了  你看着怎么弄自己做一个吧  挺简单的

2006-09-07 20:18
h_nelson
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-7-2
收藏
得分:0 

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

2007-07-02 19:36
a32853404
Rank: 1
等 级:新手上路
帖 子:4
专家分:0
注 册:2007-7-3
收藏
得分:0 

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

2007-07-03 15:45
bluekissok
Rank: 1
等 级:新手上路
帖 子:1
专家分:0
注 册:2007-7-17
收藏
得分:0 
回复:(风之舞者)飞机订票系统(数组做法)
哥们好啊
现在正在做这个 能不能给我发一个啊 谢谢咯
邮箱 qianjun200888@163.com
2007-07-17 14:03
dyjazw
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2007-7-21
收藏
得分:0 
大家瞧瞧我的:
#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);
}
}
}

2007-07-21 21:54
dyjazw
Rank: 1
等 级:新手上路
帖 子:21
专家分:0
注 册:2007-7-21
收藏
得分:0 
我还是一学生,这是我在学校的作业,有什么要改进的地方,大家指导一下啊
2007-07-21 21:58
卷入内核
Rank: 1
等 级:新手上路
帖 子:30
专家分:0
注 册:2007-7-2
收藏
得分:0 
现在的学生怎么写个简单的程序也来网上找
2007-07-23 00:56
wingyip
Rank: 1
等 级:新手上路
威 望:2
帖 子:119
专家分:0
注 册:2007-7-16
收藏
得分:0 

2007-07-24 08:13
快速回复:飞机订票系统(数组做法)
数据加载中...
 
   



关于我们 | 广告合作 | 编程中国 | 清除Cookies | TOP | 手机版

编程中国 版权所有,并保留所有权利。
Powered by Discuz, Processed in 0.035168 second(s), 7 queries.
Copyright©2004-2024, BCCN.NET, All Rights Reserved