| 网站首页 | 业界新闻 | 小组 | 威客 | 人才 | 下载频道 | 博客 | 代码贴 | 在线编程 | 编程论坛
欢迎加入我们,一同切磋技术
用户名:   
 
密 码:  
共有 7535 人关注过本帖, 1 人收藏
标题:飞机订票系统(数组做法)
只看楼主 加入收藏
风之舞者
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2006-2-26
收藏(1)
 问题点数:0 回复次数:28 
飞机订票系统(数组做法)

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

代码: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();
}

搜索更多相关主题的帖子: 订票 做法 系统 飞机 
2006-07-09 09:47
风之舞者
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2006-2-26
收藏
得分:0 

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;

}
}


2006-07-09 09:47
tanyongqing
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-7-12
收藏
得分:0 
[求助] 飞机票系统

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

2006-07-12 19:15
tanyongqing
Rank: 1
等 级:新手上路
帖 子:5
专家分:0
注 册:2006-7-12
收藏
得分:0 

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

2006-07-13 23:18
风之舞者
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2006-2-26
收藏
得分:0 

好的  ==啊


2006-07-16 01:48
jianhen
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-7-17
收藏
得分:0 

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

2006-07-17 14:09
jianhen
Rank: 1
等 级:新手上路
帖 子:2
专家分:0
注 册:2006-7-17
收藏
得分:0 
还有就是你的Welcome to use the system这个都没有显示出来,
2006-07-17 14:11
风之舞者
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2006-2-26
收藏
得分:0 
其实这个系统还是有几个错误和BUG的  还有待改进  我已经给你邮箱发过去了  有什么能够帮我改正的还请多多指教  谢谢

2006-07-18 03:36
cky1014
Rank: 1
等 级:新手上路
帖 子:10
专家分:0
注 册:2006-8-8
收藏
得分:0 
我也想看看报告参考呢,谢谢~~~
chenrainy@sina.com

2006-08-08 09:49
风之舞者
Rank: 1
等 级:新手上路
帖 子:64
专家分:0
注 册:2006-2-26
收藏
得分:0 

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


2006-08-23 01:51
快速回复:飞机订票系统(数组做法)
数据加载中...
 
   



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

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