c语言航班管理系统代码

合集下载

C语言航班管理程序标准系统

C语言航班管理程序标准系统

//---------------------航班管理程序系统---------------------//#include<stdio.h>#include<stdlib.h>#include<string.h>#include<conio.h>#define N 20void welcome()。

//定义一个欢迎界面函数 //void entrance()。

//定义一个进入界面 //void score()。

//定义一个记录查询函数 //void add()。

//定义一个添加航班的函数 //void cut()。

//定义一个删除航班的函数 //void sell()。

//定义一个售出航班的函数 //void consult()。

//定义一个按要求查询的函数 //void compos()。

//定义一个按航班号排序的函数 //void back()。

//定义一个返回函数 //void read()。

//定义一个读入函数 //void save()。

//定义一个保存函数 //int all=10。

int ans。

typedef struct flight{char flightNum[N]。

//航班号//char setPlace[N]。

//出发地//char destPlace[N]。

//目的地//int Amount。

//数量//char airCompany[N]。

//航空公司//char setTime[N]。

//出发时间//char arrTime[N]。

//到达时间//}ft。

struct flight fli[50]={{"A1001","北京","大连",1000,"北京航空公司","8:00","8:45"},{"A1002","上海","太原",2000,"春秋航空公司","4:00","5:00"},{"A1003","沈阳","长沙",2500,"东北航空公司","10:00","13:30"},{"A1014","石家庄","贵阳",3000,"河北航空公司","15:00","17:40"},{"A1005","长春","广州",4500,"长春航空公司","14:20","16:10"},{"B1006","郑州","武汉",5000,"新郑航空公司","19:30","20:10"},{"B1007","重庆","昆明",6000,"重庆航空公司","18:00","19:10"},{"B1008","厦门","兰州",7000,"厦门航空公司","6:40","8:20"},{"B1009","深圳","黑龙江",8000,"深圳航空公司","21:00","23:50"},{"B1010","海南","台北",8500,"海南航空公司","2:00","2:30"}}。

一千行机票查询与预订系统c语言代码

一千行机票查询与预订系统c语言代码
printf("\t*\t 机票查询与预定 *\n");/*菜单名称*/
printf("\t* *\n");
printf("\t* *\n");
printf("\t* 注:乘客使用请输入1,退出输入2; *\n");
printf("\t* *\n");
char c1[18],c2[18],c3[18],c4[18],c5[18],c6[18],c7[18],c8[18],c9[18];//c[]为购票人信息身份证号
int b1[12],b2[12],b3[12],b4[12],b5[12],b6[12],b7[12],b8[12],b9[12]; //b[]为购票人信息联系方式
switch(c)
{
//第二部分,分菜单;
//功能一: 单程票 机票预定菜单
d48:case 1: printf("\t* * * * * * * * * * * * * * * * * * * *\n");
printf("\t* *\n");
printf("\t* 1、乘客使用窗口 *\n") ;
float TCP;/*经济舱的价格*/
int TCT; /*经济舱票数*/
float OBP;/*公务舱价格*/
int OBT;/*公务舱票数*/
float HP; /*头等舱价格*/
int HT; /*头等舱票数*/
FILE *fp4; //订票成功存储
FILE *fp5;//未出行文件
FILE *fp6;//未完成文件

c语言 航空订票系统代码

c语言 航空订票系统代码
return q;
}
void order()
/*办理订票业务*/
{ struct airline *info;
int amount,grade;
char name[10];
info=start;
if(!(info=find())) return;/*根据客户提供的航班号进行查询,如为空,退出该模块*/
#include &quot;malloc.h&quot;
#include &lt;stdio.h&gt;
#include &lt;stdlib.h&gt;
#include &lt;string.h&gt;
}
void list()/*打印全部航线信息*/
{ struct airline *info;
int i=0;
info=start;
printf(&quot;终点站名\t航班号\t飞机号\t飞行日期\t乘员定额\t余票量\n&quot;);
while(i&lt;MAXSIZE)
{
display(info);
char date[7];/*飞行日期(星期几)*/
int tkt_amt;/*乘员定额*/
int tkt_sur;/*余票量*/
linklist *order;/*乘员名单域,指向乘员名单链表的头指针*/
linkqueue wait;/*等候替补的客户名单域,分别指向排队等候名单队头队尾的指针*/
{ printf(&quot;\n请输入您的姓名(排队订票客户):&quot;);

飞机场管理程序(c语言源代码)

飞机场管理程序(c语言源代码)
else if(airhead->waittime==0)
planedown();
}
else if(landhead->waittime==0)
planeup();
airhead->waittime--;
for(p=airhead;p!=NULL;p=p->next)
p->oiltime--;
return 1;
}
planenode* intialize(void)
{
planenode *p,*head;
int i;
i=Random(1,maxlen);
head=(planenode *)malloc(sizeof(planenode));
head->oiltime=Random(1,maxoil);
head->waittime=Random(1,maxwait);
head->next=NULL;
p=head;
while(--i)
{
p->next=(planenode *)malloc(sizeof(planenode));
{
if(airhead->oiltime==0)
{
printf("油量不足,紧急迫降!\n");
return 0;
}
else if(airhead->waittime==0)
{
printf("等待时间已到,飞机成功降落!\n");
return 0;
}
void loading(void)

飞机订票系统(C语言代码及流程图)

飞机订票系统(C语言代码及流程图)

目录第一部分源程序---------------------------------------------------3第二部分函数流程图--------------------------------------------11 menu()-----------------------------------------------------12 enter()-----------------------------------------------------13 input()-----------------------------------------------------14 browse()---------------------------------------------------15 menu1()---------------------------------------------------16 order()-----------------------------------------------------17 search_time()---------------------------------------------18 search_end()----------------------------------------------19 search()----------------------------------------------------20 book()------------------------------------------------------21 back()------------------------------------------------------22 save()------------------------------------------------------23 load()------------------------------------------------------24 第三部分心得体会------------------------------------------------25第一部分:源程序#include <stdio.h>#include <string.h>#include <stdlib.h>#define N 1000typedef struct plane{char ID[10]; /*航班代号*/char BePlace[10];/*飞机起飞地点*/char EnPlace[10];/*飞机降落终点*/char data[15];/*飞机起飞时间*/int max;/*飞机最大乘客人数*/int price;/*飞机票价*/int num;/*飞机已售票数*/}PLANE;PLANE ti[N];int n;/*当前的航班数目*/void menu();void menu1();void input(int i){printf("请输入航班代号:\n");scanf("%s",ti[i].ID);printf("请输入起飞地点:\n");scanf("%s",ti[i].BePlace);printf("请输入降落地点:\n");scanf("%s",ti[i].EnPlace);printf("请输入起飞时间:\n");scanf("%s",ti[i].data);printf("请输入航班的最大载客人数:\n");scanf("%d",&ti[i].max);printf("请输入航班的票价:\n");scanf("%d",&ti[i].price);ti[i].num=0;}void enter(){int i;system( "cls" );printf("请输入航班的数目(0-%d)?:",N);scanf("%d",&n); /*要输入的记录个数*/printf("\n请输入数据\n\n");for(i=0;i<n;i++){printf("\n请输入第%d 航班记录.\n",i+1);input(i); /*调用输入函数*/}getchar();menu();}void printf_one(int i) /*显示一个记录的函数*/{printf("%11s %6s %10s %6s %6d %6d %6d",ti[i].ID,ti[i].BePlace,ti[i].EnPlace ,ti[i].data,ti[i].price,ti[i].max,ti[i].num);}void browse(){int i;system( "cls" );puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){printf_one(i);printf("\n");}getchar();getchar();menu();}void order() /*排序模块(按平均成绩)*/{int i,j;struct plane s;system( "cls" );for(i=0;i<n;i++) /*冒泡法排序*/{for(j=i+1;j<n;j++)if(strcmp(ti[i].data,ti[j].data)>0){s=ti[i];ti[i]=ti[j];ti[j]=s;}}browse();}void search_time(){int i,m=0;struct plane s;system( "cls" );printf("\n\nEnter the time:");scanf("%s",s.data); /*输入出发的时间*/puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){if(strcmp(s.data,ti[i].data)==0){m++;if((m!=0)&&(m%10==0)) /*目的是分屏显示*/{printf("\n\nPress any key to contiune . . .");getchar();puts("\n\n");}printf_one(i);printf("\n");/*调用显示一个记录的函数*/}}puts("\n--------------------------------------------------------------------");getchar(); /*按任意健*/getchar();menu1();}void serch_end(){int i,m=0;struct plane s;system( "cls" );printf("\n\nEnter the end Place:");scanf("%s",s.EnPlace); /*输入要到达的地方*/puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){if(strcmp(ti[i].EnPlace,s.EnPlace)==0){m++;if((m!=0)&&(m%10==0)) /*目的是分屏显示*/{printf("\n\nPress any key to contiune . . .");getchar();puts("\n\n");}printf_one(i);printf("\n");/*调用显示一个记录的函数*/}}puts("\n--------------------------------------------------------------------");getchar(); /*按任意健*/getchar();menu1();}void menu1(){int n,w1;do{system( "cls" ); /*清屏*/puts("\t\t\t\t 飞机售票操作!\n\n");puts("\t\t*********************MENU*********************\n\n");puts("\t\t\t\t1.按照时间排序");puts("\t\t\t\t2.按照时间查找航班");puts("\t\t\t\t3.按照地点查找航班");puts("\t\t\t\t4.返回主菜单");puts("\n\n\t\t**********************************************\n");printf("Choice your number(1-4): [ ]\b\b");scanf("%d",&n);if(n<1||n>4) /*对选择的数字作判断*/{w1=1;printf("your choice is not between 1 and 4,Please input again:");getchar();getchar();}else w1=0;} while(w1==1);/*选择功能*/switch(n){case 1:order();break;case 2:search_time();break;case 3:serch_end();break;case 4:menu();break;}}int search() /*查找模块*/{int i,k;struct plane s;k=-1;system( "cls" );printf("\n\n请输入要订票的起飞地点:");scanf("%s",s.BePlace); /*输入要到达的地方*/printf("\n\n请输入要订票的降落地点:");scanf("%s",s.EnPlace);printf("\n\n请输入要订票的起飞时间:");scanf("%s",s.data); /*输入出发的时间*/for(i=0;i<n;i++) /*查找要修改的数据*/{if(strcmp(s.BePlace,ti[i].BePlace)==0&&strcmp(s.EnPlace,ti[i].EnPlace)==0&&strcmp(s.dat a,ti[i].data)==0){k=i; /*找到要修改的记录*/printf_one(k);break; /*调用显示一个记录的函数*/}}if(k==-1){printf("\n\nNO exist!");return -1;}elsereturn k;}void book(){int i;system( "cls" );printf("欢迎进入售票窗口!\n");i=search();if(i!=-1){if(ti[i].num>=ti[i].max){printf("\n该趟航班票已售完!");}else{ti[i].num++;printf("\n订票成功!\n");}}elseprintf("该航班不存在!\n");getchar();getchar(); /*按任意健*/menu();}void back(){int i,k=-1;struct plane s;system( "cls" );printf("欢迎进入退票窗口!\n");printf("\n\n输入航班代号:");scanf("%s",s.ID); /*输入要到达的地方*/for(i=0;i<n;i++) /*查找要修改的数据*/{if(strcmp(s.ID,ti[i].ID)==0){k=i; /*找到要修改的记录*/printf_one(k);break; /*调用显示一个记录的函数*/}}if(k==-1){printf("\n\nNO exist!");}else{ti[i].num--;printf("\n退票成功!\n");}getchar(); /*按任意健*/getchar(); /*按任意健*/menu();}void save(){int w=1;FILE *fp;int i;system( "cls" );if((fp=fopen("D:\\我的文档\\桌面\\ticket.txt","wt"))==NULL) /*以输出打开方式,在此前的记录被覆盖*/{printf("\nCannot open file\n");return ;}for(i=0;i<n;i++)if(fwrite(&ti[i],sizeof(struct plane),1,fp)!=1){printf(" error\n");w=0;}if(w==1){printf(" ok!\n");}fclose(fp);getchar();getchar();menu();}void load(){FILE *fp;int i,w;w=1;system( "cls" );if((fp=fopen("D:\\我的文档\\桌面\\ticket.txt","rt"))==NULL){printf("\nCan not open file\n");w=0;return;}n=0;for(i=0;!feof(fp);i++){fread(&ti[i],sizeof(struct plane),1,fp);n++;}n=n-1;fclose(fp);if(w==1)printf("Load !");getchar();getchar();menu();}void menu(){int n,w1;do{system( "cls" ); /*清屏*/ /*清屏*/puts("\t\t\t\t 飞机售票管理系统!\n\n");puts("\t\t*********************MENU*********************\n\n");puts("\t\t\t\t1.输入新航班");puts("\t\t\t\t2.浏览");puts("\t\t\t\t3.航班操作");puts("\t\t\t\t4.订票");puts("\t\t\t\t5.退票");puts("\t\t\t\t6.保存");puts("\t\t\t\t7.载入");puts("\t\t\t\t8.退出");puts("\n\n\t\t**********************************************\n");printf("Choice your number(1-8): [ ]\b\b");scanf("%d",&n);if(n<1||n>8) /*对选择的数字作判断*/{w1=1;printf("your choice is not between 1 and 8,Please input enter to choice again:");getchar();getchar();}else w1=0;} while(w1==1);/*选择功能*/switch(n){case 1:enter();break; /*输入模块*/case 2:browse();break; /*浏览模块*/case 3:menu1();break; /*查找模块*/case 4:book();break; /*订票模块*/case 5:back();break; /*退票模块*/case 6:save();break; /*保存模块*/case 7:load();break; /*加载模块*/case 8:exit(0);}}void main(){menu();}第二部分:函数流程图(2)enter函数流程图第三部分:心得体会(1)开始对c语言只是一种零散的认识,作为一个c语言的初学者对编程没有明确的概念,只是对语句的格式与编程规定有了一个初步了解。

航空管理系统c语言实现

航空管理系统c语言实现

#include<stdio.h>#include<stdlib.h>#include<string.h>#include<ctype.h>#define N 6#define M 150struct airline//*********************************************************飞机航班的结构定义{Charair_num[10];//**************************************************************航班号charplane_num[10];//************************************************************飞机号charstart_place[10];//**********************************************************起点站charend_place[10];//************************************************************终点站chardate[15];//*******************************************************************日期inttotal;//*********************************************************************总票数int left;//********************************************************************剩余票数}airline[N];struct customer//********************************************************客户信息的结构定义{charname[10];//*******************************************************************姓名char shenfenzheng[20];//*******************************************************身份证号charair_num[10];//**************************************************************航班号charcangwei[12];//****************************************************************仓位intpiaoshu;//********************************************************************订票数}customer[M];voidhangbanbaobiao();//***********************************************************航班报表void guanli();//***********************************************************基本信息管理函数(管理员通道)voidkehu();//*********************************************************************客户通道void luru();//*****************************************************************录入航线信息void xiugai();//***************************************************************修改信息函数void shanchu();//**************************************************************删除航线信息void hangxianchaxun();//*******************************************************航线查询函数void jipiaoyuding();//*********************************************************机票预订函数void tuidingjipiao();//********************************************************机票退订函数void zhucaidan();//**************************************************************主菜单函数void jiami(char * s,int);//********************************************************加密函数void main(){system("color 47");zhucaidan();}void zhucaidan(){int n;char mima[13];system("cls");printf("\t\t\t※*************************************※\n");printf("\t\t\t※※\n");//开始界面printf("\t\t\t※★欢迎进入宇宙航空客户管理系统!★※\n");printf("\t\t\t※※\n");printf("\t\t\t※*************************************※\n\n");printf("\t\t\t※*************************************※\n");printf("\t\t\t※※\n");printf("\t\t\t※请选择登入身份:※\n");printf("\t\t\t※管理员登入请按 1 ※\n");printf("\t\t\t※客户登入请按 2 ※\n");printf("\t\t\t※※\n");printf("\t\t\t※*************************************※\n");do//************************************************************************以防客户输错{scanf("%d",&n);if (n!=1&&n!=2)printf("\t\t输入错误,请重新输入\n");}while(n!=1&&n!=2);if(n==1)//*******************************************************************管理员登入{int cuowu=1;do{printf("\t\t请输入12位管理员密码:\n");jiami(mima,12);printf("\n");if (strcmp(mima,"xiongweizhou")==0)guanli();else{printf("\t\t密码输入错误,请注意大小写!\n");cuowu++;}if (cuowu==4){printf("\t\t对不起,你已经没有机会了!\n");printf("\t\t密码如果忘了请联系本系统管理员!\n");break;}}while(cuowu<=3&&strcmp(mima,"xiongweizhou")!=0);}if(n==2)//*********************************************************************客户登入{kehu();}}void kehu()//*********************************************************客户通道{int m;system("cls");do{printf("\t\t\t※*************************************※\n");printf("\t\t\t※※\n");printf("\t\t\t※★欢迎进入客户服务通道!★※\n");printf("\t\t\t※※\n");printf("\t\t\t※*************************************※\n\n");printf("\t\t\t※*************************************※\n");printf("\t\t\t※※\n");printf("\t\t\t※尊敬的客户您好,请选择以下操作: ※\n");printf("\t\t\t※航线查询请按 1 ※\n");printf("\t\t\t※机票预订请按 2 ※\n");printf("\t\t\t※退订机票请按 3 ※\n");printf("\t\t\t※想返回主菜单请按 4 ※\n");printf("\t\t\t※※\n");printf("\t\t\t※*************************************※\n");scanf("%d",&m);if (m!=1&&m!=2&&m!=3&&m!=4)printf("\t请按要求操作,谢谢!\n");}while(m!=1&&m!=2&&m!=3&&m!=4);if (m==1)hangxianchaxun();if (m==2)jipiaoyuding();if (m==3)tuidingjipiao();if (m==4)zhucaidan();}voidguanli()//********************************************************************基本信息管理函数{int m;system("cls");do{printf("\t\t\t※*************************************※\n");printf("\t\t\t※※\n");printf("\t\t\t※★欢迎进入管理员通道!★※\n");printf("\t\t\t※*************************************※\n\n");printf("\t\t\t※*************************************※\n");printf("\t\t\t※※\n");printf("\t\t\t※管理员您好,请选择以下操作: ※\n");printf("\t\t\t※录入航线信息请按 1 ※\n");printf("\t\t\t※修改航线信息请按 2 ※\n");printf("\t\t\t※删除航线信息请按 3 ※\n");printf("\t\t\t※打印航班报表请按 4 ※\n");printf("\t\t\t※想返回主菜单请按 5 ※\n");printf("\t\t\t※※\n");printf("\t\t\t※*************************************※\n");scanf("%d",&m);if (m!=1&&m!=2&&m!=3&&m!=4&&m!=5)printf("\t请按要求操作,谢谢!\n");}while(m!=1&&m!=2&&m!=3&&m!=4&&m!=5);if (m==1)luru();if (m==2)xiugai();if (m==3)shanchu();if (m==4)hangbanbaobiao();if (m==5)zhucaidan();}void luru()//*******************************************************录入航线信息{FILE *fp=NULL;static i=0;int fanhui;char ch='y';system("cls");if ((fp=fopen("flight.txt","a"))==NULL){printf("can not open flight.txt.\n");exit(0);}printf("\t\t\t※***********************※\n");printf("\t\t\t※★请认真输入信息!★※\n");printf("\t\t\t※***********************※\n");getchar();printf("\t\t请输入航班号:\n");gets(airline[i].air_num);printf("\t\t请输入飞机号:\n");gets(airline[i].plane_num);printf("\t\t请输入起始站:\n");gets(airline[i].start_place);printf("\t\t请输入终点站:\n");gets(airline[i].end_place);printf("\t\t请输入日期(****-**-**):\n");gets(airline[i].date);cuowu://goto标志printf("\t\t请输入总票数:\n");scanf("%d",&airline[i].total);printf("\t\t请输入余票数:\n");scanf("%d",&airline[i].left);if (airline[i].total<airline[i].left)//************************防止输入总票数小于余票数{printf("输入错误!总票数小于余票数!请重新输入!\n");goto cuowu;};fwrite(&airline[i],sizeof(airline[0]),1,fp);getchar();do{printf(" 你是否还要录入信息?是按\"y\",否按\"n\"! \n");ch=getchar();if (ch=='y'||ch=='Y'){fseek(fp,0,2);luru();}if (!(ch=='y'||ch=='n'||ch=='Y'||ch=='N'))printf("请按要求输入!\n");}while (!(ch=='y'||ch=='n'||ch=='Y'||ch=='N'));fclose(fp);if (ch=='n'||ch=='N'){fan://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2)printf("\t请按要求输入!\n");goto fan;};}}void xiugai()//******************************************************修改信息函数{int n,fanhui;system("cls");printf("\t\t请先找到要修改的航线!\n\n");chongxin://goto的标志do{printf("\t\t\t※*************************************※\n");printf("\t\t\t※※\n");printf("\t\t\t※请选择查询方式:※\n");printf("\t\t\t※航班号查询请按 1 ※\n");printf("\t\t\t※起点站查询请按 2 ※\n");printf("\t\t\t※终点站查询请按 3 ※\n");printf("\t\t\t※日期查询请按 4 ※\n");printf("\t\t\t※返回主菜单请按 5 ※\n");printf("\t\t\t※※\n");printf("\t\t\t※*************************************※\n");scanf("%d",&n);if (n!=1&&n!=2&&n!=3&&n!=4&&n!=5)printf("\t\t请按要求输入!谢谢!\n");}while(n!=1&&n!=2&&n!=3&&n!=4&&n!=5);if (n==1){FILE *fp=NULL;char hangbanhao[10];char ch;int i,cunzai=0;printf("\t\t请输入要查询的航班号:\n");scanf("%s",&hangbanhao);if ((fp=fopen("flight.txt","r+"))==NULL){printf("can not open flight.txt.\n");exit(0);}for(i=0;i<N;i++){fread(&airline[i],sizeof(airline[0]),1,fp);for (i=0;i<N;i++){if (strcmp(hangbanhao,airline[i].air_num)==0){printf("\t航班号飞机号起始站终点站日期总票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;chongshu://goto标志printf("\t\t确定要修改吗?('y'or'n')\n");getchar();ch=getchar();if(ch=='y'||ch=='Y'){getchar();printf("\t\t请输入航班号:\n");gets(airline[i].air_num);printf("\t\t请输入飞机号:\n");gets(airline[i].plane_num);printf("\t\t请输入起始站:\n");gets(airline[i].start_place);printf("\t\t请输入终点站:\n");gets(airline[i].end_place);printf("\t\t请输入日期(****-**-**):\n");gets(airline[i].date);cuowu:printf("\t\t请输入总票数:\n");scanf("%d",&airline[i].total);printf("\t\t请输入余票数:\n");scanf("%d",&airline[i].left);if (airline[i].total<airline[i].left)//********防止输入总票数小于余票数{printf("输入错误!总票数小于余票数!请重新输入!\n");goto cuowu;};fseek(fp,i*(long)(sizeof(struct airline)),0);fwrite(&airline[i],sizeof(airline[0]),1,fp);printf("\t\t已经修改成功!\n");fclose(fp);printf("\n");hui://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto hui;};}if(ch!='n'&&ch!='N'&&ch!='y'&&ch!='Y'){printf("\t\t请按要求输入,谢谢!\n");goto chongshu;}};}if (cunzai==0){printf("\t\t所查找的航班不存在,请重新选择查询方式!\n");goto chongxin;};if(ch=='n'||ch=='N'){fan://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto fan;};}}if (n==2){FILE *fp=NULL;char qishizhan[10];char hangbanhao[10];char ch;int i,cunzai=0;printf("\t\t请输入要查询的起始站:\n");scanf("%s",&qishizhan);if ((fp=fopen("flight.txt","r+"))==NULL){printf("can not open flight.txt.\n");exit(0);}for(i=0;i<N;i++){fread(&airline[i],sizeof(airline[0]),1,fp);}for (i=0;i<N;i++){if (strcmp(qishizhan,airline[i].start_place)==0){printf("\t航班号飞机号起始站终点站日期票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;}}if (cunzai==1){printf("\t\t请选择输入航班号:\n");scanf("%s",&hangbanhao);cunzai=0;}for (i=0;i<N;i++){if (strcmp(hangbanhao,airline[i].air_num)==0){printf("\t航班号飞机号起始站终点站日期总票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;chongshu2://goto标志printf("\t\t确定要修改吗?('y'or'n')\n");getchar();ch=getchar();if(ch=='y'||ch=='Y'){getchar();printf("\t\t请输入航班号:\n");gets(airline[i].air_num);printf("\t\t请输入飞机号:\n");gets(airline[i].plane_num);printf("\t\t请输入起始站:\n");gets(airline[i].start_place);printf("\t\t请输入终点站:\n");gets(airline[i].end_place);printf("\t\t请输入日期(****-**-**):\n");gets(airline[i].date);printf("\t\t请输入总票数:\n");scanf("%d",&airline[i].total);printf("\t\t请输入余票数:\n");scanf("%d",&airline[i].left);fseek(fp,i*(long)(sizeof(struct airline)),0);fwrite(&airline[i],sizeof(airline[0]),1,fp);printf("\t\t已经修改成功!\n");fclose(fp);printf("\n");hui2://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto hui2;};}if(ch!='n'&&ch!='N'&&ch!='y'&&ch!='Y'){printf("\t\t请按要求输入,谢谢!\n");goto chongshu2;}};}if (cunzai==0){printf("\t\t所查找的航班不存在,请重新选择查询方式!\n");goto chongxin;};if(ch=='n'||ch=='N'){fan2://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto fan2;};}}if (n==3){FILE *fp=NULL;char zhongdianzhan[10];char hangbanhao[10];char ch;int i,cunzai=0;printf("\t\t请输入要查询的终点站:\n");scanf("%s",&zhongdianzhan);if ((fp=fopen("flight.txt","r+"))==NULL){printf("can not open flight.txt.\n");exit(0);}for(i=0;i<N;i++){fread(&airline[i],sizeof(airline[0]),1,fp);}for (i=0;i<N;i++){if (strcmp(zhongdianzhan,airline[i].end_place)==0){printf("\t航班号飞机号起始站终点站日期总票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;}}if (cunzai==1){printf("\t\t请选择输入航班号:\n");scanf("%s",&hangbanhao);cunzai=0;}for (i=0;i<N;i++){if (strcmp(hangbanhao,airline[i].air_num)==0){printf("\t航班号飞机号起始站终点站日期总票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;chongshu3://goto标志printf("\t\t确定要修改吗?('y'or'n')\n");getchar();ch=getchar();if(ch=='y'||ch=='Y'){getchar();printf("\t\t请输入航班号:\n");gets(airline[i].air_num);printf("\t\t请输入飞机号:\n");gets(airline[i].plane_num);printf("\t\t请输入起始站:\n");gets(airline[i].start_place);printf("\t\t请输入终点站:\n");gets(airline[i].end_place);printf("\t\t请输入日期(****-**-**):\n");gets(airline[i].date);printf("\t\t请输入总票数:\n");scanf("%d",&airline[i].total);printf("\t\t请输入余票数:\n");scanf("%d",&airline[i].left);fseek(fp,i*(long)(sizeof(struct airline)),0);fwrite(&airline[i],sizeof(airline[0]),1,fp);printf("\t\t已经修改成功!\n");fclose(fp);printf("\n");hui3://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto hui3;};}if(ch!='n'&&ch!='N'&&ch!='y'&&ch!='Y'){printf("\t\t请按要求输入,谢谢!\n");goto chongshu3;};}}if (cunzai==0){printf("\t\t所查找的航班不存在,请重新选择查询方式!\n");goto chongxin;};if(ch=='n'||ch=='N'){fan3://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto fan3;};}}if (n==4){FILE *fp=NULL;char riqi[10];char hangbanhao[10];char ch;int i,cunzai=0;printf("\t\t请输入要查询的日期(****-**-**):\n");scanf("%s",&riqi);if ((fp=fopen("flight.txt","r+"))==NULL){printf("can not open flight.txt.\n");exit(0);}for(i=0;i<N;i++){fread(&airline[i],sizeof(airline),1,fp);}for (i=0;i<N;i++){if (strcmp(riqi,airline[i].date)==0){printf("\t航班号飞机号起始站终点站日期总票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;}}if (cunzai=1){printf("\t\t请选择输入航班号:\n");scanf("%s",&hangbanhao);cunzai=0;}for (i=0;i<N;i++){if (strcmp(hangbanhao,airline[i].air_num)==0){printf("\t航班号飞机号起始站终点站日期总票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;chongshu4://goto标志printf("\t\t确定要修改吗?('y'or'n')\n");getchar();ch=getchar();if(ch=='y'||ch=='Y'){getchar();printf("\t\t请输入航班号:\n");gets(airline[i].air_num);printf("\t\t请输入飞机号:\n");gets(airline[i].plane_num);printf("\t\t请输入起始站:\n");gets(airline[i].start_place);printf("\t\t请输入终点站:\n");gets(airline[i].end_place);printf("\t\t请输入日期(****-**-**):\n");gets(airline[i].date);printf("\t\t请输入总票数:\n");scanf("%d",&airline[i].total);printf("\t\t请输入余票数:\n");scanf("%d",&airline[i].left);fseek(fp,i*(long)(sizeof(struct airline)),0);fwrite(&airline[i],sizeof(airline[0]),1,fp);printf("\t\t已经修改成功!\n");fclose(fp);printf("\n");hui4://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto hui4;};}if(ch!='n'&&ch!='N'&&ch!='y'&&ch!='Y'){printf("\t\t请按要求输入,谢谢!\n");goto chongshu4;};}}if (cunzai==0){printf("\t\t所查的航班不存在,请重新选择查询方式!\n");goto chongxin;};if(ch=='n'||ch=='N'){fan4://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto fan4;};}}if (n==5)zhucaidan();if (n!=1&&n!=2&&n!=3&&n!=4&&n!=5){printf("\t\t输入错误!请按要求输入!\n");goto chongxin;};}voidshanchu()//********************************************************************** ********删除航线信息{int n,fanhui;system("cls");chongxin://goto的标志printf("\t\t请先找到要删除的航线!\n\n");do{printf("\t\t\t※*************************************※\n");printf("\t\t\t※※\n");printf("\t\t\t※请选择查询方式:※\n");printf("\t\t\t※航班号查询请按 1 ※\n");printf("\t\t\t※起始站查询请按 2 ※\n");printf("\t\t\t※终点站查询请按 3 ※\n");printf("\t\t\t※日期查询请按 4 ※\n");printf("\t\t\t※返回菜单请按 5 ※\n");printf("\t\t\t※※\n");printf("\t\t\t※*************************************※\n");scanf("%d",&n);if (n!=1&&n!=2&&n!=3&&n!=4&&n!=5)printf("请按要求输入!谢谢!\n");}while(n!=1&&n!=2&&n!=3&&n!=4&&n!=5);if (n==1){FILE *fp=NULL;char hangbanhao[10];char ch;int i,j,k,l=0,cunzai=0;printf("\t\t请输入要查询的航班号:\n");scanf("%s",&hangbanhao);if ((fp=fopen("flight.txt","r+"))==NULL){printf("can not open flight.txt.\n");exit(0);}for(i=0;i<N;i++){fread(&airline[i],sizeof(airline[0]),1,fp);}while(isdigit(*airline[l].air_num)){l++;}for (i=0;i<N;i++){if (strcmp(hangbanhao,airline[i].air_num)==0){j=i+1;printf("\t航班号飞机号起始站终点站日期总票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;chongshu:printf("\t\t确定要删除吗?('y'or'n') \n");getchar();ch=getchar();if(ch=='y'||ch=='Y'){fseek(fp,j*(long)(sizeof(struct airline)),0);for(k=j;k<l;k++){fread(&airline[k-1],sizeof(airline[0]),1,fp);}fclose(fp);if ((fp=fopen("flight.txt","w"))==NULL){printf("can not open flight.txt.\n");exit(0);}for(j=0;j<l-1;j++){fwrite(&airline[j],sizeof(airline[0]),1,fp);}printf("\t\t已经删除成功!\n");fclose(fp);printf("\n");fan://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto fan;};}if(ch=='n'||ch=='N')shanchu();if(ch!='n'&&ch!='N'&&ch!='y'&&ch!='Y'){printf("\t\t请按要求输入,谢谢!\n");goto chongshu;};}}if (cunzai==0){printf("\t\t所查找的航班不存在,请重新选择查询方式!\n");goto chongxin;};}if (n==2){FILE *fp=NULL;char qishizhan[10];char hangbanhao[10];char ch;int i,j,k,l=0,cunzai=0;printf("\t\t请输入要查询的起始站:\n");scanf("%s",&qishizhan);if ((fp=fopen("flight.txt","r+"))==NULL){printf("can not open flight.txt.\n");exit(0);}for(i=0;i<N;i++){fread(&airline[i],sizeof(airline[0]),1,fp);}while(isdigit(*airline[l].air_num)){l++;}for (i=0;i<N;i++){if (strcmp(qishizhan,airline[i].start_place)==0){printf("\t航班号飞机号起始站终点站日期总票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;}}if (cunzai==1){printf("\t\t请选择输入航班号:\n");scanf("%s",&hangbanhao);cunzai=0;}for (i=0;i<N;i++){if (strcmp(hangbanhao,airline[i].air_num)==0){j=i+1;printf("\t航班号飞机号起始站终点站日期总票数余票\n");printf("\t%-10s",airline[i].air_num);printf("%-10s",airline[i].plane_num);printf("%-10s",airline[i].start_place);printf("%-10s",airline[i].end_place);printf("%-14s",airline[i].date);printf("%-8d",airline[i].total);printf("%-8d",airline[i].left);printf("\n");cunzai=1;chongshu2://goto标志printf("\t\t确定要删除吗?('y'or'n') \n");getchar();ch=getchar();if(ch=='y'||ch=='Y'){fseek(fp,j*(long)(sizeof(struct airline)),0);for(k=j;k<l;k++){fread(&airline[k-1],sizeof(airline[0]),1,fp);}fclose(fp);if ((fp=fopen("flight.txt","w"))==NULL){printf("can not open flight.txt.\n");exit(0);}for(j=0;j<l-1;j++){fwrite(&airline[j],sizeof(airline[0]),1,fp);}printf("\t\t已经删除成功!\n");fclose(fp);printf("\n");fan2://goto标志printf("返回主菜单请按1,返回管理员通道请按2!\n");scanf("%d",&fanhui);if (fanhui==1)zhucaidan();if (fanhui==2)guanli();if (fanhui!=1&&fanhui!=2){printf("\t请按要求输入!\n");goto fan2;};}if(ch=='n'||ch=='N')shanchu();if(ch!='n'&&ch!='N'&&ch!='y'&&ch!='Y'){printf("\t\t请按要求输入,谢谢!\n");goto chongshu2;};}}if (cunzai==0){printf("\t\t所查找的航班不存在,请重新选择查询方式!\n");goto chongxin;};}if (n==3){FILE *fp=NULL;char zhongdianzhan[10];char hangbanhao[10];char ch;int i,j,k,l=0,cunzai=0;printf("\t\t请输入要查询的终点站:\n");scanf("%s",&zhongdianzhan);if ((fp=fopen("flight.txt","r+"))==NULL){printf("can not open flight.txt.\n");。

数据结构航班管理系统

数据结构航班管理系统

#include <stdafx.h> #include <stdio.h>#include <string.h>#define maxspace 100 #define keylen 7#define radix_n 10#define radix_c 26 typedef char keytype; typedef struct{char start[6];char end[6];char sche[10];char time1[5];char time2[5];char model[4];int price;}infotype;typedef struct{keytype keys[keylen]; infotype others;int next;}slnode;typedef struct{slnode sl[maxspace];int keynum;int length;}sllist;typedef int arrtype_n[radix_n];typedef int arrtype_c[radix_c];void distribute(slnode *sl,int i,arrtype_n f,arrtype_n e) {int j,p;for(j=0;j<radix_n;j++){f[j]=e[j]=0;}for(p=sl[0].next;p;p=sl[p].next){j=sl[p].keys[i]%48;if(!f[j])f[j]=p;elsesl[e[j]].next=p;e[j]=p;}}void collect(slnode *sl,int i,arrtype_n f,arrtype_n e) {int j,t;for(j=0;!f[j];j++);sl[0].next=f[j];t=e[j];while(j<radix_c-1){for(j=j+1;j<radix_c-1&&!f[j];j++);if(f[j]){sl[t].next=f[j];t=e[j];}}sl[t].next=0;}void radixsort(sllist &l)//链式{int i;arrtype_n fn,en;arrtype_c fc,ec;for(i=0;i<l.length;i++)l.sl[i].next=i+1;l.sl[l.length].next=0;for(i=l.keynum-1;i>=2;i--) {distribute(l.sl,i,fn,en); collect(l.sl,i,fn,en);}for(i=1;i>=0;i--){distribute_c(l.sl,i,fc,ec); collect_c(l.sl,i,fc,ec);}}void arrange(sllist &l)//重新整理{int p,q,i;slnode temp;p=l.sl[0].next;for(i=1;i<l.length;i++){while(p<i)p=l.sl[p].next;q=l.sl[p].next;if(p!=i){temp=l.sl[p];l.sl[p]=l.sl[i];l.sl[i]=temp;l.sl[i].next=p;}p=q;}}int binsearch(sllist l,keytype key[]) {int low,high,mid;low=1;high=l.length;while(low<=high){mid=(low+high)/2;if(strcmp(key,l.sl[mid].keys)==0)return mid;else if(strcmp(key,l.sl[mid].keys)<0)high=mid-1;elselow=mid+1;}return 0;}void seqsearch(sllist l,keytype key[],int i){int j,k,m=0;printf("***************************************************** ********\n");printf("*航班号起点站终点站航班期起飞时间到达时间机型票价*\n");for(j=1;j<=l.length;j++){switch(i){case 2:k=strcmp(key,l.sl[j].others.start);break;case 3:k=strcmp(key,l.sl[j].others.end);break;case 4:k=strcmp(key,l.sl[j].others.time1);break;case 5:k=strcmp(key,l.sl[j].others.time2);break;}if(k==0){m=1;printf("* %-8s%-7s%-6s%-11s%-9s%-7s%-5s%4d *\n",l.sl[j].keys,l.sl[j].others.start,l.sl[j].others.end,l.sl[j].others.sche,l.sl[j].others.time1,l.sl[j].others.time2,l.sl [j].others.model,l.sl[j].others.price);}}if(m==0)printf("* 无此航班信息,可能输入错误!*\n");printf("***************************************************** ********\n");}void searchcon(sllist l){keytype key[keylen];int i=1,k;while(i>=1&&i<=5){printf("\********************\n");printf(" * 航班信息查询系统\n");printf(" ********************\n");printf(" * 1.航班号*\n");printf(" * 2.起点站*\n");printf(" * 3.终点站*\n");printf(" * 4.起飞时间*\n");printf(" * 5.到达时间*\n");printf(" * 0.退出系统*\n");printf(" ********************\n");printf(" 请选择(0-5):");scanf("%d",&i);printf("\n");switch(i){case 1:printf("输入要查询的航班号(字母要大写):"); scanf("%s",key);k=binsearch(l,key);printf("***************************************************** ********\n");if(k==0)printf("*无此航班信息,可能输入错误!*\n");else {printf("* 航班号起点站终点站航班期起飞时间到达时间机型票价*\n");printf("* %-8s%-7s%-6s%-11s%-9s%-7s%-5s%4d *\n",l.sl[k].keys,l.sl[k].others.start,l.sl[k].others.end,l.sl[k].others.sche,l.sl[k].others.time1,l.sl[k].others.time2,l. sl[k].others.model,l.sl[k].others.price);}printf("***************************************************** ********\n");break;case 2:printf("输入要查询的航班起点站名:");scanf("%s",key);seqsearch(l,key,i);break;case 3:printf("输入要查询的航班终点站名:");scanf("%s",key);seqsearch(l,key,i);break;case 4:printf("输入要查询的航班起飞时间:");scanf("%s",key);seqsearch(l,key,i);break;case 5:printf("输入要查询的航班到达时间:");scanf("%s",key);seqsearch(l,key,i);break;case 0:printf("\n\n\n再见\n\n\n");}}}void inputdata(sllist &l){int i=++l.length;char yn='y';while(yn=='y'||yn=='Y'){printf("航班号起点站终点站航班期起飞时间到达时间机型票价\n");scanf("%s%s%s%s%s%s%s%d",l.sl[i].keys,l.sl[i].others.start,l.sl[i].others.e nd,l.sl[i].others.sche,l.sl[i].others.time1,l.sl[i].others.time2,l.sl[i].others.model, &l.sl [i].others.price);++i; getchar();radixsort(l);arrange(l);printf("继续输入吗?y/n:");scanf("%c",&yn);}l.length=i-1;}void main(){sllist l;l.keynum=6;l.length=0;inputdata(l);searchcon(l);}//数据结构编写航班信息查询系统//航班信息查询系统数据结构课程设计_梦里水乡_百度空间第十三章:干燥通过本章的学习,应熟练掌握表示湿空气性质的参数,正确应用空气的H–I 图确定空气的状态点及其性质参数;熟练应用物料衡算及热量衡算解决干燥过程中的计算问题;了解干燥过程的平衡关系和速率特征及干燥时间的计算;了解干燥器的类型及强化干燥操作的基本方法。

c语言实现机票管理系统源代码(总3页)

c语言实现机票管理系统源代码(总3页)

c语言实现机票管理系统源代码(总3页)-CAL-FENGHAI.-(YICAI)-Company One1-CAL-本页仅作为文档封面,使用请直接删除/*2、管理员账户为:boss,密码为:123。

保存在txt文件中,需要修改请于程序中修改*//*3、部分文件读写为二进制读写,所以打开文件时会看到乱码*/#include <>#include <>#include <>#include<>#define N 1000void zhujiemian();um,s[i].start,s[i].over,s[i].time,s[i].count,s[i].prize umber=0;strcpy(user[0].Name,"boss");strcpy(user[0].sexual,"male");user[0].age=22;user[0].power=1;strcpy(user[0].ps,"123");fwrite(&user[0],sizeof(user),1,fp);fclose(fp);}elsefclose(fp);again:printf("请输入管理员姓名:");scanf("%s",;ame,==0&&strcmp(user[i].ps,==0){success=1;break;}}if(success==1) umber=={printf("该身份证号码已被使用过!\n请重新输入身份证号:");scanf("%ld",&;i=0;umber=;printf("姓名:");scanf("%s",&user[i].Name);user[i].Name[19]='\0';printf("性别:");scanf("%s",&user[i].sexual);printf("用户密码:");scanf("%s",&user[i].ps);printf("年龄:");scanf("%d",&user[i].age);n++;入航班信息☆-------- -------------------**\n\n" " **-------- ----☆ 2. 浏览航班信息☆----- ------------------**\n\n" " **-------- ☆ 3. 查找航班信息-☆-------- ------------**\n\n" " **-------- ---☆ 4.对航班按航班票价排序---☆-----------------------**\n\n" " **-------- ------☆ 5. 订票信息-☆-------- -----------------**\n\n" " **-------- ----------☆ 0.退出 -☆-------- ---------------------**\n\n" " **-------- ---------------☆☆-------- -------------------------**\n\n" " **-------- -----------------☆ -------- --------------------------**\n\n" " **-------- ---------------☆☆-------- --------------------------**\n\n");printf("========================================================= =======================\n");printf("请在0-5中选择以回车键结束:\n\n");scanf("%d",&j);switch(j){case 1:input();浏览航班信息☆----- ------------------**\n\n" " **-------- ☆ 2. 查找航班信息 -☆-------- ------------**\n\n" " **-------- ---☆ 3.对航班按航班票价排序---☆-----------------------**\n\n" " **-------- ------☆ 4. 订票信息-☆-------- -----------------**\n\n" " **-------- ----------☆ 0.退出 -☆-------- ---------------------**\n\n" " **-------- ---------------☆☆-------- -------------------------**\n\n" " **-------- -----------------☆ -------- --------------------------**\n\n" " **-------- ---------------☆☆-------- --------------------------**\n\n");printf("========================================================= =======================\n");printf("请在0-5中选择以回车键结束:\n\n");scanf("%d",&j);switch(j){case 1:system("cls");print();um=={printf("该航班已经存在!\n请重新输入:");scanf("%d",&;i=0;um=;printf("请输入起始站:\n");scanf("%s",s[i].start);ver);ime);ount);rize);rize>s[i+1].prize)o=s[i].num;ame1,s[i].start);ame2,s[i].over);ime,s[i].time);ount=s[i].count;rize=s[i].prize;um=p[0].no;tart,p[0].name1);ver,p[0].name2);ime,p[0].time);ount=p[0].count;rize =p[0].prize;}}}save();um==no)ount!=0&&s[i].count>=n)ount=s[i].count-n;save();ount<n)//判断是否出错{printf("余票不足,请输入有效的机票数!\n");getchar();}printf("是否继续订票请输入yes或no以回车键结束:\n");//判断是否继续订票scanf("%s",a);}while(!strcmp(a,"yes"));//判断结束getchar();printf("按ENTER键返回用户主界面。

航班查询系统 C语言源程序

航班查询系统  C语言源程序

#include 〈stdio、h>#include<stdlib、h〉#include<string、h〉#define NOD struct plane_liststruct plane{char number[10];char start[10];char arrive [10];chardate[10];char starttime[10];chararrivingtime[10];char price[10];charmodel[10];};NOD{char number [10];char start[10];char arrive [10];char date[10];charstarttime[10];char arrivingtime[10];char price[10];charmodel[10];NOD*next;};FILE *fp;/*由文件中得数据生成一个飞机航班得链表,如果文件不存在,则就是一个空链表*/ NOD*load(char planename[]){NOD *p,*q,*head;structplaneper;p=(NOD *)malloc(sizeof(NOD));q=head=NULL;if((fp=fopen(planename,"rb"))==NULL)ﻩreturn head;else{while(!feof(fp)){if(fread(&per,sizeof(struct plane),1,fp)==1){p=(NOD*)malloc(sizeof(NOD));strcpy(p->number,per、number);strcpy(p->start,per、start);strcpy(p->arrive,per、arrive);strcpy(p—>date,per、date);strcpy(p->starttime,per、starttime);ﻩstrcpy(p—>arrivingtime,per、arrivingtime);strcpy(p—>price,per、price);strcpy(p-〉model,per、model);ﻩhead=p;p—〉next=q;q=head;}}}fclose(fp);return(head);}/*输入*/NOD *insert(NOD *head){NOD *temp,*p;p=head;temp=(NOD*)malloc(sizeof(NOD));printf(”\n\t请输入航班号:”);scanf("%s",temp—>number);printf("\n\t请输入起点站:");scanf("%s”,temp—>start);printf(”\n\t请输入终点站:");scanf("%s”,temp->arrive);printf(”\n\t请输入起飞时间:”);scanf("%s”,temp->starttime);printf("\n\t请输入到达时间:”);scanf(”%s”,temp->arrivingtime);printf("\n\t请输入班期:”);scanf("%s",temp—〉date);printf("\n\t请输入票价:");scanf(”%s",temp—〉price);printf("\n\t请输入航班型号:");scanf(”%s",temp—>model);head=temp;temp—〉next=p;return head;}/*保存*/void save(NOD *head,char[]){NOD*p;structplane per;if((fp=fopen(,"wb”))==NULL){printf("文件无法写入");exit(0);}else{p=head;while(p!=NULL){ strcpy(per、number,p—〉number);strcpy(per、start,p—〉start);ﻩstrcpy(per、arrive,p->arrive);strcpy(per、date,p—>date);strcpy(per、starttime,p-〉starttime);ﻩstrcpy(per、arrivingtime,p—〉arrivingtime);strcpy(per、price,p->price);strcpy(per、model,p-〉model);if(fwrite(&per,sizeof(structplane),1,fp)!=1)ﻩ{printf("文件不能写入数据,请检查后重新运行、\n");ﻩexit(0);ﻩ}p=p—>next;}fclose(fp);}}/*显示*/void display(NOD*head){ NOD *p;p=head;while(p!=NULL){ printf("航班号:%s\n”,p—>number);printf(”起点站:%s\n”,p-〉start);printf(”终点站:%s\n",p-〉arrive);printf("班期:%s\n”,p-〉date);printf("起飞时间:%s\n”,p->starttime);ﻩprintf("到达时间:%s\n",p->arrivingtime);printf("票价:%s\n”,p—>price);printf(”飞机型号:%s\n”,p-〉model);p=p-〉next;}}/*航班号查找*/void finda(NOD*head){ NOD*p;char number[10];printf("请输入查找航班得编号:”);scanf("%s”,number);p=head;while (p!=NULL){ if(strcmp(number,p—〉number)==0){printf("航班号:%s\n",p—>number);printf(”起点站:%s\n”,p—>start);printf(”终点站:%s\n",p->arrive);printf("班期:%s\n",p->date);printf(”起飞时间:%s\n”,p->starttime);printf(”到达时间:%s\n",p-〉arrivingtime);printf(”票价:%s\n",p—>price);printf("飞机型号:%s\n”,p-〉model);break;}elseﻩp=p->next;}if(p==NULL)ﻩprintf("\n\t查无此航班\n");}/*起点站查找*/voidfindb(NOD *head){NOD *p;char start[10];printf("请输入查找航班得起点站:");scanf(”%s”,start);p=head;while(p!=NULL){if(strcmp(start,p-〉start)==0){printf(”航班号:%s\n",p->number);printf(”起点站:%s\n",p—〉start);printf(”终点站:%s\n",p->arrive);printf(”班期:%s\n",p—〉date);printf("起飞时间:%s\n",p—〉starttime);printf(”到达时间:%s\n",p->arrivingtime);printf("票价:%s\n”,p->price);printf("飞机型号:%s\n",p->model);ﻩbreak;}elseﻩp=p->next;}if(p==NULL)printf("\n\t查无此航班\n”);}/*终点站查找*/void findc(NOD*head){NOD *p;char arrive[10];printf("请输入查找航班得终点站:”);scanf("%s”,arrive);p=head;while (p!=NULL){if(strcmp(arrive,p->arrive)==0){printf(”航班号:%s\n",p->number);printf(”起点站:%s\n",p—>start);printf("终点站:%s\n",p—>arrive);printf("班期:%s\n",p->date);printf("起飞时间:%s\n",p->starttime);printf("到达时间:%s\n”,p-〉arrivingtime);printf(”票价:%s\n",p—〉price);printf("飞机型号:%s\n",p->model);break;}elseﻩp=p—>next;}if(p==NULL)printf("\n\t查无此航班\n");}/*起飞时间查找*/void findd(NOD *head){ NOD *p;char starttime[10];printf("请输入查找航班得起飞时间:");scanf("%s”,starttime);p=head;while(p!=NULL){if(strcmp(starttime,p->starttime)==0){printf("航班号:%s\n",p->number);printf("起点站:%s\n",p—〉start);printf("终点站:%s\n”,p->arrive);printf(”班期:%s\n",p—〉date);printf("起飞时间:%s\n",p-〉starttime);printf(”到达时间:%s\n",p—>arrivingtime);printf("票价:%s\n",p—〉price);printf("飞机型号:%s\n”,p->model);ﻩbreak;}elsep=p-〉next;}if(p==NULL)printf("\n\t查无此航班\n");}/*到达时间查找*/void finde(NOD*head){NOD *p;chararrivingtime[10];printf(”请输入查找航班得到达时间:");scanf(”%s",arrivingtime);p=head;while (p!=NULL){if(strcmp(arrivingtime,p—〉arrivingtime)==0){printf("航班号:%s\n”,p-〉number);printf("起点站:%s\n",p—〉start);printf(”终点站:%s\n”,p->arrive);printf("班期:%s\n",p-〉date);printf("起飞时间:%s\n”,p—>starttime);ﻩprintf("到达时间:%s\n",p->arrivingtime);printf("票价:%s\n",p-〉price);printf("飞机型号:%s\n",p—〉model);break;}elseﻩp=p—〉next;}if(p==NULL)printf(”\n\t查无此航班\n”);}/*删除*/NOD *dele(NOD *head){NOD *p,*q;char number[5];printf(":请输入要删除得航班编号”);scanf("%s”,number);p=q=head;while(p!=NULL){if(strcmp(number,p->number)==0){ﻩif(head==p)ﻩﻩhead=p—>next;ﻩelseq->next=p->next;ﻩfree(p);ﻩbreak;}else{q=p;p=p—>next;}}if(p==NULL)printf(”\n\t查无此航班\n”);returnhead;}/*主函数*/voidmain(){ NOD*head;char fnum[10];int choise;printf("\n\t欢迎光临航班查询系统:");scanf("%s”,fnum);head=load(fnum);while(1){printf("\n\t\t 航班信息检索与查询\n");printf("\t\t********************************\n”);printf("\t\t1、航班号查找\n”);printf("\t\t 2、起点站查找\n");printf(”\t\t 3、终点站查找\n");printf("\t\t4、起飞时间查找\n");printf("\t\t5、到达时间查找\n");printf("\t\t6、航班号删除\n");printf(”\t\t7、增加新航班\n");printf("\t\t 8、显示所有航班\n");printf("\t\t 9、存盘并退出\n”);printf(”\n\t请选择1—9:");scanf("%d”,&choise);switch(choise){ case 1:finda(head);break;case 2:findb(head);break;case 3:findc(head);break;case4:findd(head);break;case 5:finde(head);break;case 6:head=dele(head);break;ﻩcase 7:head=insert(head);break;ﻩcase 8:display(head);break;ﻩ case9:save(head,fnum);exit(0);default:printf("输入错误,重新输入\n");ﻩ }} }。

C语言飞行控制代码设计

C语言飞行控制代码设计

C语言飞行控制代码设计一、引言飞行控制是飞机飞行过程中最核心的部分之一,其关系到飞行的稳定性和安全性。

而C语言是一种高效且广泛应用于嵌入式系统开发的编程语言。

本文将介绍基于C语言的飞行控制代码设计,着重讨论飞行控制的功能需求和代码设计方法。

二、功能需求1. 飞行模式选择飞行控制代码应该能够支持多种飞行模式的选择,例如手动模式、自动模式、自动驾驶模式等。

通过定义枚举类型或宏常量的方式,实现对不同飞行模式的控制和切换。

2. 姿态控制飞行控制代码需要实现对飞机的姿态进行控制。

姿态控制包括飞行器的横滚角、俯仰角和偏航角的控制。

可以使用PID控制算法或其他控制方法来实现姿态控制。

3. 高度控制飞行控制代码应该能够实现对飞机的高度进行控制。

高度控制包括飞行器的爬升率和目标飞行高度的控制。

可以使用高度保持控制方法或其他合适的算法来实现高度控制。

4. 航向控制飞行控制代码需要实现对飞机的航向进行控制。

航向控制包括对飞行器的飞行方向和航线进行控制。

可以使用航向保持控制方法或其他合适的算法来实现航向控制。

5. 自动导航飞行控制代码可以根据导航系统提供的导航信息,自动进行导航飞行。

当飞机工作在自动驾驶模式下时,飞行控制代码应该能够根据导航信息进行自动飞行、导航和着陆控制。

三、代码设计方法1. 模块化设计飞行控制代码应该按照功能需求进行模块化设计。

可以将不同的功能模块划分为不同的函数或文件,提高代码的复用性和可维护性。

例如,可以将姿态控制功能作为一个独立的函数,并在主程序中调用。

2. 数据结构设计为了方便管理和传递数据,飞行控制代码应该设计合适的数据结构。

可以使用结构体或类来表示飞行器的状态和控制参数。

通过定义全局变量或将数据结构作为函数参数传递,实现数据的共享与传递。

3. 状态机设计飞行控制代码可以使用状态机的思想进行设计。

通过定义不同的状态和状态转移条件,实现对不同飞行模式和控制状态的切换和控制。

状态机设计有助于代码的可读性和灵活性。

航空管理系统

航空管理系统

void main()//主函数{int c;do{printf("\n航空订票系统\n");printf("\n\t**************************\n");printf("\n 1录入航班信息\n");printf("\n 2修改航班信息\n");printf("\n 3查询航班信息\n");printf("\n 4显示航班信息\n");printf("\n 5订票\n");printf("\n 6退票\n");printf("\n 7显示订票信息\n");printf("\n 0退出系统\n");printf("\n\t**************************\n");printf("请选择操作: ");scanf("%d",&c);switch(c){case 1:printf("您选择录入航班信息:\n");insert();break;case 2:printf("您选择修改航班信息:\n");modify();break;case 3:printf("您选择查询航班信息:\n");query();break;case 4:printf("您选择显示航班信息:\n");showf();break;case 5:printf("您选择订票:\n");booktk();break;case 6:printf("您选择退票:\n");backtk();break;case 7:printf("您选择显示订票信息:\n");showb();break;case 0:printf("您选择退出订票系统:\n");break;default:fprintf(stderr,"select error!\n");}}while(c!=0);printf("\n*****谢谢您的使用!欢迎您的下次使用*****\n");void booktk()//订票{int n,x,y,i;char a[10];FILE *fp,*fb;//定义文件指针char name1[20], ii[10];bookticket b[N];do{printf("\n请输入终点站名称:");scanf("%s",name1);//读取终点站if((fp=fopen("flight.dat","rb"))==NULL){fprintf(stderr,"can not open the file!\n");exit(-1);}rewind(fp);for(i=0;i<N;i++)fread(&air[i],sizeof(struct flight),1,fp);for(i=0;i<N;i++){if(strcmp(air[i].destination,name1)==0)//按终点站起始站判定输出条件{y=i;printf("查找航班信息成功! \n");printf("\n航班号起飞时间降落时间起点终点票价折扣余票量\n");printf(PRINT);break;}}printf("\n没有您需要的信息或查找完毕! 是否继续查找 ?请键入 yes 或 no 以回车键结束 ");scanf("%s",ii);}while(strcmp(ii,"yes")==0);//判定结束fclose(fp);if((fb=fopen("bt.dat","ab"))==NULL)//打开文件,并判定是否出错{printf("创建文件失败!");//打印出错提示getchar();return;}i=0;while((fread(&b[i],sizeof(struct bookticket),1,fb)==1) && i<N){fread(&b[i],sizeof(struct bookticket),1,fb);i++;x=i;}fclose(fb);do{printf("\n请输入您要订的机票数以回车键结束:");scanf("%d",&n);//读取所订机票数if(n<0){printf("\n请输入有效的机票数!");//判定机票数是否出错break;}if(air[y].capcity <n)//判定是否出错{printf("\n请输入有效的机票数:");break;}if(air[y].capcity!=0 && air[y].capcity>=n)//判定是否出错{air[y].capcity =air[y].capcity-n;//航班中可载客量减去订票数wr();printf("\n请输入订单号 :");scanf("%d",&bt.ticketnum);printf("\n");printf("请输入客户姓名:");scanf("%s",bt.clientname);printf("\n");printf("请输入客户证件号:");scanf("%s",bt.clientnum);printf("\n");bt.total =n;bt.fnum =air[y].fnum ;}break;printf("\n是否继续?请输入yes或no以回车键结束: ");//判定是否继续订票scanf("%s",a);}while(!strcmp(a,"yes"));//判定结束if((fb=fopen("bt.dat","rb+"))==NULL)//打开文件,并判定是否出错{printf("创建文件失败!");//打印出错提示getchar();return;}i=0;while(i<x){fseek(fb,i*sizeof(struct bookticket),SEEK_SET);fwrite(&b[i],sizeof(struct bookticket),1,fb);i++;}fseek(fb,0L,SEEK_END);//将输入的写入位置放到文件尾fwrite(&bt,sizeof(bt),1,fbfwrite(&bt,sizeof(struct bookticket),1,fb);printf("\n订票成功 !");fclose(fb);}void backtk()//退票模块{int i=0,n;char name[MAX];char a[MAX];FILE *fb,*fp;if((fb=fopen("bt.dat","wb"))==NULL)//打开文件,并判定是否出错{printf("创建文件失败 !");//打印出错提示getchar();return;}printf("\n请输入您的姓名:");scanf("%s%*c",name);rewind(fb);while(!feof(fb) && !ferror(fb)){fread(&bt,sizeof(struct bookticket),1,fb);if(!strcmp(name,bt.clientname)){ printf("\n您的订票信息如下:\n");printf(PRINT1);break;}else printf("\n没有您需要的信息!");break;exit(-1);}fclose(fb);do{printf("\n请输入您要退的机票数以回车键结束:");scanf("%d",&n);//读取所订机票数if(n<0){printf("\n请输入有效的机票数!");//判定机票数是否出错break;}if(bt.total<n){printf("\n请输入有效的机票数:");break;}if((fp=fopen("flight.dat","r+w"))==NULL){fprintf(stderr,"can not open the file!\n");exit(-1);}rewind(fp);for(i=0;i<N;i++){fread(&air[i],sizeof(struct flight),1,fp);if(air[i].fnum ==bt.fnum )//判定是否出错{air[i].capcity =air[i].capcity+n;break;}}fclose(fp);wr();printf("\n是否继续?请输入yes或no以回车键结束: ");//判定是否继续订票scanf("%s",a);}while(!strcmp(a,"yes"));//判定结束if((fb=fopen("bt.dat","rb+"))==NULL) //打开文件,并判定是否出错{printf("创建文件失败 !");//打印出错提示getchar();return;}bt.total =bt.total-n;//这个地方还有点问题, 只能保存一个订票信息fseek(fb,0L,SEEK_END);//将输入的写入位置放到文件尾fwrite(&bt,sizeof(struct bookticket),1,fb);fclose(fb);printf("\n退票成功 !");}void wr()//将航班flight.dat信息写入文件{FILE *ff;//定义文件指针int i;if((ff=fopen("flight.dat","wb"))==NULL)//打开文件并判定是否出错{printf("创建文件失败 !");//打印出错提示getchar();return;}for(i=0;i<N;i++)if(fwrite(&air[i],sizeof(struct flight),1,ff)==0) //向文件写入数据,并判定是否出错printf("向文件输入数据失败!\n ");fclose(ff);//关闭文件}void query()//查询航班信息{char name1[20];char ii[10];int n,no,i;FILE *fp;do{printf("请选择查找方式:\n");//打印查询方式菜单printf("1.按航班号查找\n");printf("2.按终点站查找 \n");printf("0.返回 \n");printf("\n请在 0-2 中选择: ");scanf("%d",&n);//读取查找方式if(n==0) break;switch(n){case 1:printf("请输入航班号 :");scanf("%d",&no);//航班号break;case 2:printf("请输入终点站名称:");scanf("%s",name1);//读取终点站break;}if((fp=fopen("flight.dat","rb"))==NULL){fprintf(stderr,"can not open the file!\n");exit(-1);}rewind(fp);for(i=0;i<N;i++)fread(&air[i],sizeof(struct flight),1,fp);for(i=0;i<N;i++){if(strcmp(air[i].destination,name1)==0)//按终点站起始站判定输出条件{printf("查找航班信息成功! \n");printf("航班号起飞时间降落时间起点终点票价折扣余票量\n");printf(PRINT);printf("\n");break;}if(air[i].fnum ==no)//按航班号判定输出条件{printf("查找航班信息成功! \n");printf("\n票价折扣航班号余票量起飞时间\n");降落时间起点终点printf(PRINT);printf("\n");break;}}printf("\n没有您需要的信息或查找完毕! 是否继续查找?请键入yes或no以回车键结束");scanf("%s",ii);}while(strcmp(ii,"yes")==0);//判定结束fclose(fp);。

C语言版航空系统

C语言版航空系统

//readme:when you login as administrator,please login the name:admin and the password admin. // as in vc the time is not as same as the TC,so I give up showing the time.// if there are only little comments in files,it may be in dead rolling,because I have not judge the end of the file.#include<stdio.h>#include<string.h>void displaymainmenu(); //显示主菜单void displayadminmenu(); //显示管理人菜单void loginadmin(); //管理员验证void displayusermenu(); //显示用户菜单void loginuser(); //用户身份验证void storeflight(); //存储航班信息void adminviewflights(); //管理员显示航班信息void userviewflights(); //用户显示航班信息void storeuser(); //存储用户信息void booktickets(); //订票函数void viewtickets(); //显示订票信息int index; //登陆用户的位置FILE *pflight; //航班文件FILE *pticket; //票文件FILE *puser; //用户文件FILE *padmin; //管理员文件//定义user的结构体struct user{char name[20];char email[20];char password[20];char phone[15];}user[20];//定义flight的结构体struct flight{char flightnumber[20];char airline[20];char source[20];char destination[20];float price;}flight[20];struct ticket{char flightnumber[20];char name[30];int passages;//Struct date dateofjourneydouble totalamount;}ticket[20];void main(){printf("Welcome to visit the ticket sold system:\n");displaymainmenu();}//主菜单函数void displaymainmenu(){int choice;printf("1.Login as administrator:\n");printf("2.Login as user:\n");printf("3.New user:\n");printf("4.Exit\n ");printf("\n");printf("Enter your choice:\n");scanf("%d",&choice);switch(choice){case 1:loginadmin(); //需要判断管理员身份,在文件中设置一个管理员的账号,由这个验证函数进行验证.displayadminmenu(); //显示管理人菜单后可能还需要再显示主菜单,这个要注意测试一下break;case 2:loginuser(); //用户身份验证displayusermenu(); //显示用户菜单break;case 3:storeuser(); //存储用户信息break;case 4:exit(1);break;default:displaymainmenu();break;}}//管理人菜单函数void displayadminmenu(){int choice;printf("1.Register Flights information\n");printf("2.View Flights:\n");printf("3.Exit:\n ");printf("\n");printf("Enter your choice:\n");scanf("%d",&choice);switch(choice){case 1:storeflight(); //存储航班信息break;case 2:adminviewflights(); //显示航班信息break;case 3:printf("Thanks for your using.\n");displaymainmenu(); //显示主菜单break;default:displayadminmenu(); //显示主菜单break;}}//存储新用户void storeuser(){struct user user1,*u;u=&user1;puser=fopen("d:\\users.txt","a");printf("==============New user registration please enter details==============");printf("Enter your name:\n");scanf("%s",&);printf("Enter your e-mail:\n");scanf("%s",&user1.email);printf("Enter your password:\n");scanf("%s",&user1.password);printf("Enter your phone number:\n");scanf("%s",&user1.phone);//向文件中输入信息fprintf(puser,"%s %s %s %s ",,user1.email,user1.password,user1.phone);// fwrite(u,sizeof(struct user),1,puser);printf("Store success.\n");fclose(puser);displaymainmenu();}//管理员登陆void loginadmin() //比较登陆{struct user admin;char s[20];char t[20];padmin=fopen("d:\\admin.txt","r");printf("Enter your name:\n");scanf("%s",&);printf("Enter your password:\n");scanf("%s",&admin.password);//比较的过程fscanf(padmin,"%s%s%s",&s,&t,&t);if(!(strcmp(s,))&&!(strcmp(t,admin.password)))printf("Welcome administrator.\n");else{printf("Sorry,your enter is wrong!\n");displaymainmenu();}}//用户登陆void loginuser(){int i=0;char s[20];char t[20];puser=fopen("d:\\users.txt","r");printf("Enter your name:\n");scanf("%s",&s);printf("Enter your password:\n");scanf("%s",&t);for(i=0;i<20;i++){fscanf(puser,"%s%s%s%s",&user[i].name,&user[i].email,&user[i].password,&user[i].phone);if(!(strcmp(s,user[i].name))&&!(strcmp(t,user[i].password))){printf("Welcome %s.\n",s);index=i;break;}}if(i>=20){printf("Sorry,your enter is wrong.\n");displaymainmenu();}}void storeflight() //存储航班信息{struct flight flightx;pflight=fopen("d:\\flights.txt","a");printf("===========New Flight Registeration Please Enter Details==========\n");printf("Enter the flightnumber:\n");scanf("%s",&flightx.flightnumber);printf("Enter airline:\n");scanf("%s",&flightx.airline);printf("Enter source:\n");scanf("%s",&flightx.source);printf("Enter destination:\n");scanf("%s",&flightx.destination);printf("Enter the price:\n");scanf("%f",&flightx.price);fprintf(pflight,"%s %s %s %s %f ",flightx.flightnumber,flightx.airline,flightx.source,flightx.destination,flightx.price);printf("Flight Registered success.\n");fclose(pflight);displayadminmenu();}void adminviewflights() //管理员查询航班信息the information of flights to administration{int i=0;char s[20];pflight=fopen("d:\\flights.txt","r");printf("Enter flightnumber:\n");scanf("%s",&s);for(i=0;i<20;i++){fscanf(pflight,"%s%s%s%s%f",&flight[i].flightnumber,&flight[i].airline,&flight[i].source,&f light[i].destination,&flight[i].price);if(!(strcmp(flight[i].flightnumber,s))){printf("%s--%s--%s--%s--%f\n",flight[i].flightnumber,flight[i].airline,flight[i].source,flight[i].destination,flight[i].price);break;}}if(i>=20)printf("Sorry,there is no this airline\n");displayadminmenu();}void userviewflights() //用户查询航班信息the information of flights to users{int i=0;char s[20];pflight=fopen("d:\\flights.txt","r");printf("Enter flightnumber:\n");scanf("%s",&s);for(i=0;i<20;i++){fscanf(pflight,"%s%s%s%s%f",&flight[i].flightnumber,&flight[i].airline,&flight[i].source,&f light[i].destination,&flight[i].price);if(!(strcmp(flight[i].flightnumber,s))){printf("%s--%s--%s--%s--%f\n",flight[i].flightnumber,flight[i].airline,flight[i].source,flight[i] .destination,flight[i].price);break;}}if(i>=20)printf("Sorry,there is no this airline\n");displayadminmenu();}void displayusermenu() //user menu{int choice;printf("1.View flights:\n");printf("2.Book tickets:\n");printf("3.View tickets:\n");printf("4.back:\n");printf("\n");do{printf("Enter your choice please:\n");scanf("%d",&choice);}while(choice<0||choice>9);switch(choice){case 1:userviewflights();break;case 2:booktickets();break;case 3:viewtickets();break;case 4:displaymainmenu();break;default:displayusermenu();break;}}void booktickets() //the function of booking ticket {int i,j=0;pticket=fopen("d:\\tickets.txt","a");pflight=fopen("d:\\flights.txt","r");printf("Enter the flight number:\n");scanf("%s",&ticket[j].flightnumber);printf("Enter your name:\n");scanf("%s",&ticket[j].name);printf("Enter the number of passages:\n");scanf("%d",&ticket[j].passages);for(i=0;i<20;i++){fscanf(pflight,"%s%s%s%s%f",&flight[i].flightnumber,&flight[i].airline,&flight[i].source,&f light[i].destination,&flight[i].price);if(!(strcmp(flight[i].flightnumber,ticket[j].flightnumber))){ticket[j].totalamount=ticket[j].passages*flight[i].price;printf("Total number is %f\n",ticket[j].totalamount);fprintf(pticket,"%s %s %d %f ",ticket[j].flightnumber,ticket[j].name,ticket[j].passages,ticket[j].totalamount); //读入file中printf("store success.\n");break;}}if(i>=20)printf("sorry,there is no this flight.\n");displayusermenu();}void viewtickets() //the information without date.{int j;pticket=fopen("d:\\tickets.txt","r");for(j=0;j<20;j++){fscanf(pticket,"%s%s%d%f",&ticket[j].flightnumber,&ticket[j].name,&ticket[j].passages,&ti cket[j].totalamount);if(!(strcmp(ticket[j].name,user[index].name))){printf("Yout booked ticket is :%s--%s--%d--%f\n",ticket[j].flightnumber,ticket[j].name,ticket[j].passages,ticket[j].totalamoun t);}}displayusermenu();}。

C语言课程设计_飞机订票系统源代码

C语言课程设计_飞机订票系统源代码

#include<stdio.h> //标准输入、输出头文件#include<string.h> //包含字符串函数处理头文件#include<process.h> //包含access函数的头文件#define N 9999 //定义最多的航班数#define PRINT "%d\t\t%s\t\t%s\t\t星期%s\t\t%d\n ",s[i].num,s[i].start,s[i].over,s[i].time,s[i].count //宏定义输出格式struct air //定义结构体数组{int num; //定义航班号char start[20]; //航班起始站char over[20]; //终点站char time[10]; //飞行时间int count; //机票数量}s[N];int i,m=0; //定义全局变量char ii[10];void add(); //函数声明增加航班信息函数void print(); //显示航班信息void search(); //查找航班信息void dingpiao(); //订票业务void tuipiao(); //退票void read(); //读取文件void save(); //保存文件void output(); //输出格式void paixu(); //航班排序void chushihua(); //系统初始化void build(); //建立数据文件void paixu1(); //按航班号从小到大排序void paixu2(); //从大到小void main() //主函数{int j;chushihua(); //系统初始化判断是否存在原始数据文件printf(" 欢迎使用飞机订票系统\n"); //打印出系统主界面do{printf("============================================================ ==================== ");printf("1.增加航班信息\n""\t2.浏览航班信息\n""\t\t3.查找航班信息(按航班号)\t\t╮(╯_╰)╭\n""\t\t\t4.航班排序(按航班号)\n""\t\t\t\t5.订票业务\n""\to(︶︿︶)o\t\t\t6.退票业务\n""\t\t\t\t\t\t0.退出\n");printf("======================================================== ======================== ");printf("请在0-6中选择以回车键结束:");scanf("%d",&j);switch(j){case 1: add(); //调用增加航班函数break;case 2:print(); //调用显示模块break;case 3:search(); //调用查找模块break;case 4:paixu(); //调用排序函数break;case 5:dingpiao(); //调用订票模块break;case 6:tuipiao(); //调用退票模块break;case 0: //退出系统save();printf("谢谢使用,再见!");break;}}while(j!=0); //判断是否调用其他函数}void chushihua() //定义系统初始化函数{if(access("hangban.dat",0)){build();}elseread();}void build() //定义建立数据文件函数{FILE *fp; //定义文件指针if((fp=fopen("hangban.dat","wb"))==NULL) //打开文件并判定是否出错{printf("创建文件失败! "); //打印出错提示getchar();return;}printf("请依次输入航班信息(以回车键结束):\n"); //打印提示信息printf("-------------------------------------------------------------------------- \n");for(i=0;i<N;i++){printf("请输入航班号: ");scanf("%d",&s[i].num); //输入航班号printf("请输入起始站: ");scanf("%s",s[i].start); //输入起始站printf("请输入终点站: ");scanf("%s",s[i].over); //输入终点站printf("请输入时间(星期几): ");scanf("%s",s[i].time); //输入时间printf("请输入机票数: ");scanf("%d",&s[i].count); //输入机票数fwrite(&s[i],sizeof(struct air),1,fp);m++;printf("添加完毕,是否继续添加?请键入y或n以回车键结束:");scanf("%s",ii);if(strcmp(ii,"y")!=0) //判断是否继续添加航班信息{fclose(fp); //关闭文件return;}}}void read() //定义读取文件函数{FILE *fp;if((fp=fopen("hangban.dat","r"))==NULL){printf("创建文件失败! ");getchar();return;}i=0;while(!feof(fp)){fread(&s[i],sizeof(struct air),1,fp); //逐块读取数据i++;m++; //计算存在航班数}m--;fclose(fp);}void save() //定义保存函数{FILE *fp;if((fp=fopen("hangban.dat","wb"))==NULL){printf("创建文件失败! ");getchar();return;}for(i=0;i<m;i++) //逐块保存数据fwrite(&s[i],sizeof(struct air),1,fp);fclose(fp);}void add() //定义增加航班信息函数{do{printf("请依次输入您要增加的航班信息(以回车键结束): \n"); //打印提示信息printf("-------------------------------------------------------------------------- \n");printf("请输入航班号: ");scanf("%d",&s[m].num); //读取航班号printf("请输入起始站: ");scanf("%s",s[m].start); //读取起始站printf("请输入终点站: ");scanf("%s",s[m].over); //读取终点站printf("请输入时间: ");scanf("%s",s[m].time); //读取时间printf("请输入机票数: ");scanf("%d",&s[m].count); //读取机票数m++;printf("添加完毕,是否继续添加?请键入y或n以回车键结束:");scanf("%s",ii);}while(!strcmp(ii,"y")); //判断是否继续添加}void output() //定义输出格式函数{printf("航班号\t\t起始站\t\t终点站\t\t时间\t\t机票数\n"); //信息标题for(i=0;i<m;i++)printf(PRINT);//打印出信息}void print() //定义显示航班信息函数{printf("\n目前我们有如下航班:\n");output(); //调用输出格式函数printf("\n请按回车键返回上层菜单");getchar();getchar();}void search() //定义查询函数{int n;do{printf("\n请输入航班号:");scanf("%d",&n); //输入查询的航班号for(i=0;i<m;i++){if(s[i].num==n) //按航班号判定输出条件{printf("\n您所查找的航班信息为:\n ");printf("航班号\t\t起始站\t\t终点站\t\t时间\t\t机票数\n\n");printf(PRINT); //显示信息printf("\n查询完毕,按回车键继续");getchar();getchar();return;}}printf("\n对不起,没有您需要的信息!\n ");printf("是否重新查找?请键入y或n以回车键结束");scanf("%s",ii);}while(!strcmp(ii,"y"));//判定是否重新查找}void dingpiao() //定义订票业务函数{int n;char a[10]="y";do{search(); //调用查询模块if(!strcmp(ii,"n")){printf("对不起!没有找到您所需要的航班,所以不能订票。

c语言航班管理系统代码

c语言航班管理系统代码

c语言航班管理系统代码c语言航班管理系统代码#include#include#include#define N 10000struct air{int num;char start[20];char over[20];char time[10];int count;}s[N];int i;int m=0;#define PRINT "%-dsssd\",s.num,s.start,s.over,s.time,s.count void input(); void print();void save();void read();void search();void shanchu();void dingpiao();void tuipiao();void xiugai();void main(){int j;printf(" ★---您好,欢迎进入中国民航管理系统!---★\");printf("===================================== ===========================================\");do{printf(" --------☆ 1.输入航班信息☆-------- \\"" --------☆ 2.浏览航班信息☆-------- \\"" --------☆ 3.修改航班信息☆-------- \\"" --------☆ 4.查找航班信息☆-------- \\"" --------☆ 5.删除航班信息☆-------- \\"" --------☆ 6.订票信息☆-------- \\"" --------☆7.退票信息☆-------- \\"" --------☆0.退出☆--------\\");printf("===================================== ===========================================\");printf("请在0-7中选择以回车键结束:\\"); scanf("%d",&j);switch(j){case 1: input();break;case 2:print();break;case 3:xiugai();break;case 4:search();break;case 5:shanchu();break;case 6:dingpiao();break;case 7:tuipiao();break;case 0:;break;}}while(j!=0);。

飞机订票系统(C语言代码及流程图)

飞机订票系统(C语言代码及流程图)

目录第一部分源程序---------------------------------------------------3第二部分函数流程图--------------------------------------------11 menu()-----------------------------------------------------12 enter()-----------------------------------------------------13 input()-----------------------------------------------------14 browse()---------------------------------------------------15 menu1()---------------------------------------------------16 order()-----------------------------------------------------17 search_time()---------------------------------------------18 search_end()----------------------------------------------19 search()----------------------------------------------------20 book()------------------------------------------------------21 back()------------------------------------------------------22 save()------------------------------------------------------23 load()------------------------------------------------------24 第三部分心得体会------------------------------------------------25第一部分:源程序#include <stdio.h>#include <string.h>#include <stdlib.h>#define N 1000typedef struct plane{char ID[10]; /*航班代号*/char BePlace[10];/*飞机起飞地点*/char EnPlace[10];/*飞机降落终点*/char data[15];/*飞机起飞时间*/int max;/*飞机最大乘客人数*/int price;/*飞机票价*/int num;/*飞机已售票数*/}PLANE;PLANE ti[N];int n;/*当前的航班数目*/void menu();void menu1();void input(int i){printf("请输入航班代号:\n");scanf("%s",ti[i].ID);printf("请输入起飞地点:\n");scanf("%s",ti[i].BePlace);printf("请输入降落地点:\n");scanf("%s",ti[i].EnPlace);printf("请输入起飞时间:\n");scanf("%s",ti[i].data);printf("请输入航班的最大载客人数:\n");scanf("%d",&ti[i].max);printf("请输入航班的票价:\n");scanf("%d",&ti[i].price);ti[i].num=0;}void enter(){int i;system( "cls" );printf("请输入航班的数目(0-%d)?:",N);scanf("%d",&n); /*要输入的记录个数*/printf("\n请输入数据\n\n");for(i=0;i<n;i++){printf("\n请输入第%d 航班记录.\n",i+1);input(i); /*调用输入函数*/}getchar();menu();}void printf_one(int i) /*显示一个记录的函数*/{printf("%11s %6s %10s %6s %6d %6d %6d",ti[i].ID,ti[i].BePlace,ti[i].EnPlace ,ti[i].data,ti[i].price,ti[i].max,ti[i].num);}void browse(){int i;system( "cls" );puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){printf_one(i);printf("\n");}getchar();getchar();menu();}void order() /*排序模块(按平均成绩)*/{int i,j;struct plane s;system( "cls" );for(i=0;i<n;i++) /*冒泡法排序*/{for(j=i+1;j<n;j++)if(strcmp(ti[i].data,ti[j].data)>0){s=ti[i];ti[i]=ti[j];ti[j]=s;}}browse();}void search_time(){int i,m=0;struct plane s;system( "cls" );printf("\n\nEnter the time:");scanf("%s",s.data); /*输入出发的时间*/puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){if(strcmp(s.data,ti[i].data)==0){m++;if((m!=0)&&(m%10==0)) /*目的是分屏显示*/{printf("\n\nPress any key to contiune . . .");getchar();puts("\n\n");}printf_one(i);printf("\n");/*调用显示一个记录的函数*/}}puts("\n--------------------------------------------------------------------");getchar(); /*按任意健*/getchar();menu1();}void serch_end(){int i,m=0;struct plane s;system( "cls" );printf("\n\nEnter the end Place:");scanf("%s",s.EnPlace); /*输入要到达的地方*/puts("\n--------------------------------------------------------------------");printf("\n\t航班代号起飞地点降落地点起飞时间票价最大乘客已售票数\n");for(i=0;i<n;i++){if(strcmp(ti[i].EnPlace,s.EnPlace)==0){m++;if((m!=0)&&(m%10==0)) /*目的是分屏显示*/{printf("\n\nPress any key to contiune . . .");getchar();puts("\n\n");}printf_one(i);printf("\n");/*调用显示一个记录的函数*/}}puts("\n--------------------------------------------------------------------");getchar(); /*按任意健*/getchar();menu1();}void menu1(){int n,w1;do{system( "cls" ); /*清屏*/puts("\t\t\t\t 飞机售票操作!\n\n");puts("\t\t*********************MENU*********************\n\n");puts("\t\t\t\t1.按照时间排序");puts("\t\t\t\t2.按照时间查找航班");puts("\t\t\t\t3.按照地点查找航班");puts("\t\t\t\t4.返回主菜单");puts("\n\n\t\t**********************************************\n");printf("Choice your number(1-4): [ ]\b\b");scanf("%d",&n);if(n<1||n>4) /*对选择的数字作判断*/{w1=1;printf("your choice is not between 1 and 4,Please input again:");getchar();getchar();}else w1=0;} while(w1==1);/*选择功能*/switch(n){case 1:order();break;case 2:search_time();break;case 3:serch_end();break;case 4:menu();break;}}int search() /*查找模块*/{int i,k;struct plane s;k=-1;system( "cls" );printf("\n\n请输入要订票的起飞地点:");scanf("%s",s.BePlace); /*输入要到达的地方*/printf("\n\n请输入要订票的降落地点:");scanf("%s",s.EnPlace);printf("\n\n请输入要订票的起飞时间:");scanf("%s",s.data); /*输入出发的时间*/for(i=0;i<n;i++) /*查找要修改的数据*/{if(strcmp(s.BePlace,ti[i].BePlace)==0&&strcmp(s.EnPlace,ti[i].EnPlace)==0&&strcmp(s.dat a,ti[i].data)==0){k=i; /*找到要修改的记录*/printf_one(k);break; /*调用显示一个记录的函数*/}}if(k==-1){printf("\n\nNO exist!");return -1;}elsereturn k;}void book(){int i;system( "cls" );printf("欢迎进入售票窗口!\n");i=search();if(i!=-1){if(ti[i].num>=ti[i].max){printf("\n该趟航班票已售完!");}else{ti[i].num++;printf("\n订票成功!\n");}}elseprintf("该航班不存在!\n");getchar();getchar(); /*按任意健*/menu();}void back(){int i,k=-1;struct plane s;system( "cls" );printf("欢迎进入退票窗口!\n");printf("\n\n输入航班代号:");scanf("%s",s.ID); /*输入要到达的地方*/for(i=0;i<n;i++) /*查找要修改的数据*/{if(strcmp(s.ID,ti[i].ID)==0){k=i; /*找到要修改的记录*/printf_one(k);break; /*调用显示一个记录的函数*/}}if(k==-1){printf("\n\nNO exist!");}else{ti[i].num--;printf("\n退票成功!\n");}getchar(); /*按任意健*/getchar(); /*按任意健*/menu();}void save(){int w=1;FILE *fp;int i;system( "cls" );if((fp=fopen("D:\\我的文档\\桌面\\ticket.txt","wt"))==NULL) /*以输出打开方式,在此前的记录被覆盖*/{printf("\nCannot open file\n");return ;}for(i=0;i<n;i++)if(fwrite(&ti[i],sizeof(struct plane),1,fp)!=1){printf("file write error\n");w=0;}if(w==1){printf("file save ok!\n");}fclose(fp);getchar();getchar();menu();}void load(){FILE *fp;int i,w;w=1;system( "cls" );if((fp=fopen("D:\\我的文档\\桌面\\ticket.txt","rt"))==NULL){printf("\nCan not open file\n");w=0;return;}n=0;for(i=0;!feof(fp);i++){fread(&ti[i],sizeof(struct plane),1,fp);n++;}n=n-1;fclose(fp);if(w==1)printf("Load file ok!");getchar();getchar();menu();}void menu(){int n,w1;do{system( "cls" ); /*清屏*/ /*清屏*/puts("\t\t\t\t 飞机售票管理系统!\n\n");puts("\t\t*********************MENU*********************\n\n");puts("\t\t\t\t1.输入新航班");puts("\t\t\t\t2.浏览");puts("\t\t\t\t3.航班操作");puts("\t\t\t\t4.订票");puts("\t\t\t\t5.退票");puts("\t\t\t\t6.保存");puts("\t\t\t\t7.载入");puts("\t\t\t\t8.退出");puts("\n\n\t\t**********************************************\n");printf("Choice your number(1-8): [ ]\b\b");scanf("%d",&n);if(n<1||n>8) /*对选择的数字作判断*/{w1=1;printf("your choice is not between 1 and 8,Please input enter to choice again:");getchar();getchar();}else w1=0;} while(w1==1);/*选择功能*/switch(n){case 1:enter();break; /*输入模块*/case 2:browse();break; /*浏览模块*/case 3:menu1();break; /*查找模块*/case 4:book();break; /*订票模块*/case 5:back();break; /*退票模块*/case 6:save();break; /*保存模块*/case 7:load();break; /*加载模块*/case 8:exit(0);}}void main(){menu();}第二部分:函数流程图(2)enter函数流程图第三部分:心得体会(1)开始对c语言只是一种零散的认识,作为一个c语言的初学者对编程没有明确的概念,只是对语句的格式与编程规定有了一个初步了解。

  1. 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
  2. 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
  3. 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。

#include<stdio.h>#include<string.h>#include<stdlib.h>#define N10000struct air{int num;char start[20];char over[20];char time[10];int count;}s[N];int i;int m=0;#define PRINT"%-dsssd\n",s.num,s.start,s.over,s.time,s.countvoid input();void print();void save();void read();void search();void shanchu();void dingpiao();void tuipiao();void xiugai();void main(){int j;printf("★---您好,欢迎进入中国民航管理系统!---★\n");printf("============================================================================== ==\n");do{printf("--------☆ 1.输入航班信息☆--------\n\n""--------☆ 2.浏览航班信息☆--------\n\n""--------☆ 3.修改航班信息☆--------\n\n""--------☆ 4.查找航班信息☆--------\n\n""--------☆ 5.删除航班信息☆--------\n\n""--------☆ 6.订票信息☆--------\n\n""--------☆7.退票信息☆--------\n\n""--------☆0.退出☆--------\n\n");printf("============================================================================== ==\n");printf("请在0-7中选择以回车键结束:\n\n");scanf("%d",&j);switch(j){case1:input();break;case2:print();break;case3:xiugai();break;case4:search();break;case5:shanchu();break;case6:dingpiao();break;case7:tuipiao();break;case0:;break;}}while(j!=0);printf("谢谢使用,再见!\n");}void input(){char f[]="2008china";int y;printf("请输入密码并以回车键结束:\n\n");scanf("%s",f);if(strcmp(f,"2008china")==0){printf("请依次输入航班信息(机票数位0结束输入):\n\n""完成输入信息请键入w以回车键结束\n\n");printf("--------------------------------------------------------------------------\n");for(i=0;i<N;i){printf("请输入航班号:\n");scanf("%d",&s.num);printf("请输入起始站:\n");scanf("%s",s.start);printf("请输入终点站:\n");scanf("%s",s.over);printf("请输入时间:\n");scanf("%s",s.time);printf("请输入机票数:\n",m);scanf("%d",&s.count);m;printf("第%d个信息已经输完是否继续?按任意键继续,按0结束",m); scanf("%d",&y);if(y==0){save();print();break;}}}elseprintf("输入密码错误!请检查您的密码是否正确!谢谢!再见!\n\n");}void save(){FILE*fp,*fp1;if((fp=fopen("chen.dat","wb"))==NULL){printf("创建文件失败!\n\n");getchar();return;}if((fp1=fopen("hao.dat","wb"))==NULL){printf("创建文件失败!\n\n");getchar();return;}for(i=0;i<m;i)if(fwrite(&s,sizeof(struct air),1,fp)==0)printf("向文件输入数据失败!\n\n");(0)•回复•1楼•2006-07-28 22:28•举报|个人企业举报垃圾信息举报•••60.20.134.*•fprintf(fp1,"%d",m);fclose(fp);fclose(fp1);}void read(){FILE*fp,*fp1;if((fp=fopen("chen.dat","rb"))==NULL){printf("出错,请检查文件是否存在,按任意键返回住菜单"); getchar();}if((fp1=fopen("hao.dat","rb"))==NULL){printf("创建文件失败!\n\n");getchar();return;}fscanf(fp1,"%d",&m);fclose(fp1);for(i=0;i<m;i){fread(&s,sizeof(air),1,fp);}fclose(fp);}void print(){char w[10];read();printf("航班号起始站终点站时间机票数\n");{printf(PRINT);}printf("请按任意键回车键结束返回上层菜单以:\n"); scanf("%s",w);}void search(){char name1[20];char name2[20];char ii[10];int n,no;do{printf("请选择查找方式:\n\n");printf("1.按航班号查找\n\n""2.按终点站查找\n\n""3.按航线查找\n\n""0.返回\n\n");printf("请在0-3中选择:\n\n""按其他键以回车键结束返回主菜单:\n\n"); scanf("%d",&n);if(n==0)break;switch(n){case1:printf("请输入航班号:\n");scanf("%d",&no);break;case2:printf("请输入终点站名称:\n");scanf("%s",name2);break;case3:printf("请输入起始站名称:\n");scanf("%s",name1);printf("请输入终点站名称:\n");scanf("%s",name2);break;}read();{if(strcmp(s.over,name1)==0||strcmp(s.over,name2)==0){printf("\n查找航班信息成功!\n");printf("航班号起始站终点站时间机票数\n"); printf(PRINT);break;}if(s.num==no){printf("\n查找航班信息成功!\n");printf("航班号起始站终点站时间机票数\n"); printf(PRINT);break;}}no=0;//将航班号赋值为0printf("没有您需要的信息或查找完毕:\n\n""是否继续查找?请键入yes或no以回车键结束\n"); scanf("%s",ii);}while(strcmp(ii,"yes")==0);}void shanchu(){char name1[20];char name2[20];char ii[10];char f[]="2008china";int no,n;printf("请输入密码并以回车键结束:\n\n");scanf("%s",f);//读取密码if(strcmp(f,"2008china")==0){do{printf("请选择删除以方式回车键结束:\n\n");printf("*1.按航班号删除\n\n""*2.按航线删除\n\n""*0.返回\n\n");printf("请在0-2中选择以回车键结束:\n");scanf("%d",&n);if(n==0)break;switch(n){case1:printf("请输入航班号:\n");scanf("%d",&no);read();break;case2:printf("请输入起始站名称:\n");scanf("%s",name1);printf("请输入终点站名称:\n");scanf("%s",name2);read();break;}for(i=0;i<m;i){if(s.num==no||strcmp(s.start,name1)==0&&strcmp(s.over,name2)==0) {s=s[m-1];m--;}}printf("查找完毕或没有这个信息\n\n");printf("是否继续删除\n");printf("请键入yes或no以回车键结束\n");scanf("%s",ii);save();//调用读取函数if(!strcmp(ii,"yes"))/printf("请按任意键以回车键结束返回上层菜单:\n");break;}while(n!=1&&n!=2&&n!=3&&n!=4&&n!=0);回复•2楼•2006-07-28 22:28•举报|个人企业举报垃圾信息举报•••60.20.134.*•}elseprintf("对不起密码错误!您不是管理员,不能使用此项功能!谢谢!再见!\n\n"); }void dingpiao(){int n;char a[10];do{search();printf("请输入您要订的机票数以回车键结束:\n");scanf("%d",&n);if(n<0){printf("请输入有效的机票数!\n");break;}if(s.count!=0&&s.count>=n){s.count=s.count-n;save();printf("订票成功!\n\n");break;}if(s.count<n){printf("请输入有效的机票数:\n");break;}printf("是否继续?请输入yes或no以回车键结束:\n");//判断是否继续订票scanf("%s",a);}while(!strcmp(a,"yes"));}void tuipiao(){int n;char a[10];do{search();printf("请输入您要退的机票数目:\n");scanf("%d",&n);if(n<0)printf("请输入有效的机票数!\n");s.count=s.count n;save();printf("退票成功!\n\n");printf("是否继续?请键入yes或no以回车键结束:\n\n"); scanf("%s",a);}while(!strcmp(a,"yes"));getchar();}void xiugai(){struct xiu{int no;char name1[20];char name2[20];char time[20];int count;}x[1];char j[10];char f[]="2008china";int n;printf("请输入密码并以回车键结束:\n\n");scanf("%s",f);if(strcmp(f,"2008china")==0){read();/do{printf("请选择修改方式:\n\n""*1,按航班号修改:\n\n""*2,按航线修改:\n\n");printf("请在1---2中修改以回车键结束:\n\n");scanf("%d",&n);switch(n){case1:printf("请输入航班号:\n");scanf("%d",&x[0].no);break;case2:printf("请输入起始站:\n");scanf("%s",x[0].name1);printf("请输入终点站:\n");scanf("%s",x[0].name2);break;}for(i=0;i<m;i){if(strcmp(s.over,x[0].name1)==0&&strcmp(s.over,x[0].name2)==0){printf("航班号起始站终点站时间机票数\n");printf(PRINT);break;}if(s.num==x[0].no){printf("航班号起始站终点站时间机票数\n");printf(PRINT);break;}}x[0].no=0;printf("请输入新航班号、起始站、终点站、时间(星期几)、机票数:\n"); scanf("%d%s%s%s%d",&x[0].no,x[0].name1,x[0].name2,x[0].time,&x[0].count);s.num=x[0].no;strcpy(s.start,x[0].name1);strcpy(s.over,x[0].name2);strcpy(s.time,x[0].time);s.count=x[0].count;save();printf("是否继续?请键入yes或no以回车键结束:\n\n");scanf("%s",j);}while(strcmp(j,"yes")==0);}elseprintf("对不起密码错误!您不是管理员,不能使用此项功能!谢谢!再见!\n\n"); }struct air{intnum;char start[20]; char over[20]; char time[10]; int count;}s[N];。

相关文档
最新文档