⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ¿㦤

📁 几个开发用的小程序,很容易懂的,非常实用,大家可以
💻
字号:
飞机订票系统--原创(待续)分类:C/C++
主题:飞机订票系统



//Predefine 

//#include <conio.h>  clrscr(); 清屏函数在TURBO C中

#include <stdio.h> //include printf() 

#include <stdlib.h>//include exit()

#include <string.h>//include gets(char str[]) strcpy() strcmp()

#define PN   10  

#define TM   20

#define RC   15

#define CN   20

#define CEN  20

#define DT   10

#define MaxP 10  //最大航班数

//航班与订票信息结构

typedef struct PlaneInfro{

       char  date[DT];

       char  PlaneName[PN];

       char  Time[TM];

       char  ReachCity[RC];

       float Price;

       float Counter;    //折扣

       float FinaPrice;

       int   Seateds;    //已订票数

       int   Leaveseats; //剩余票数

       int   Fullseats;

}PlaneInf;

//客户资料结构

typedef struct ClientInfro{

       char  PlaneName[PN];

       char  ClientName[CN];

       char  CertifyNum[CEN];

       char  Date[30];        //订票日期

       int   BookPage;    //订单号

       int   Bookcounter; //订票数

}ClientInf;

////数据信息

int Pn=0,Page=0;              //Pn is Planenumbers,Page is BookPages

       PlaneInf  PIF[MaxP];     //relate PlaneInf.dat 其中航班数组下标与订票数组下标一一映射对应

 

//*********************Preload.c*************************************/ 

//预先载入航班数据信息

void LodePIF(){

       FILE *fp;//文件指针

 

       if((fp=fopen("PlaneInf.dat","rb"))==NULL)

              {fprintf(stderr," PlaneInf.dat is not exist!\n");

              return;

              }

       else while(fread(&PIF[Pn],sizeof(PlaneInf),1,fp)==1) Pn++;            

       fclose(fp);                           

}

//获取初始订单号

void GetPage(){

       FILE *fp;//文件指针

 

       if((fp=fopen("ClientInf.dat","rb"))==NULL)

       {

              fprintf(stderr,"ClientInf.dat is not exist!\n");

              return;//page=0

       }

       else {fseek(fp,0,2);

                Page=ftell(fp)/sizeof(ClientInf);//Page follow the end of File

                fclose(fp);

              }

}

//***

void Preload(){

       printf("载入数据!!!\n");

       GetPage();

       LodePIF();

       //clrscr();>>>>>>

}

 

//*********************BookFace().c*************************************/

//显示界面

void BookFace(){

       printf("\t*****************************************************\n");

       printf("\t\t    BOOK SYSTEM\n");

       printf("\t\t1.录入航班信息\n");

       printf("\t\t2.查询航班信息\n");

       printf("\t\t3.订票\n");

       printf("\t\t4.退票\n");

       printf("\t\t5.修改航班信息\n");

       printf("\t\t6.显示全部航班信息\n");

       printf("\t\t7.显示全部客户信息\n");

       printf("\t\t8.显示全部定票信息\n");

       printf("\t\t9.退出\n");

       printf("\t*****************************************************\n");

       printf("请选择相应选项的数值以启动相应功能:\n");

}

//************************AddPlaInf().c**********************************/

//获取航班信息

void Input_PIF(){

       char str[10];

 

       printf("请输入航班号:\n");

       gets(PIF[Pn].PlaneName);

       printf("请输入起飞日期 :\n");

       gets(PIF[Pn].date);

       printf("请输入起降时间  :\n");

       gets(PIF[Pn].Time);

       printf("请输入抵达城市  :\n");

       gets(PIF[Pn].ReachCity);

       printf("请输入票价  :\n");

       gets(str);PIF[Pn].Price=atof(str);

       printf("请输  折扣  :\n");

       gets(str);PIF[Pn].Counter=atof(str);

       printf("请输入满座数  :\n");

       gets(str);PIF[Pn].Fullseats=PIF[Pn].Leaveseats=atoi(str);

       PIF[Pn].FinaPrice=PIF[Pn].Counter*PIF[Pn].Price;

       PIF[Pn].Seateds=0;

}

 

//录入航班信息

void AddPlaInf(){

       char ch='y',str[4];

       //clrscr();>>>>>>

       printf("请输入相应的 航班号  起飞日期  起降时间     抵达城市 票价   折扣 满座数\n");

       printf("     example NS001   9.10      9:30-10:30   wuhan    300.0  0.9  50\n");

       while(ch!='N'&&ch!='n')

       {  

              Input_PIF(); //获取航班信息       

              Pn++;            //航班指针后移

              printf("退出?[N or n]继续?[any key]:\n");

              gets(str);

              ch=str[0];

       }

       //clrscr();>>>>>>

       BookFace();

}

//*************************InquireInf().c*********************************/

//判断该航班是否存在

//可传入 航班名 或者 抵达城市 判断

int IshavePla(int pos,char str[]){

 

       for(;pos<Pn&&(strcmp(str,PIF[pos].PlaneName)!=0&&strcmp(str,PIF[pos].ReachCity)!=0);pos++);

       if(pos<Pn) return pos;//成功则 还回该航班所在位子

       else return -1;//OR RETURN -1

}

//**

void Inquire(){

              char str[20];

              int k=0;

              void DisplayPn(int k);

 

              gets(str);

              if(Pn!=0){//没有录入航班信息

                     while((k=IshavePla(k,str))>=0)//找到该航班;

                            {DisplayPn(k);

                             k++;

                            }

                     printf("对不起,没有该航班的信息!!\n");

              }

              else printf("对不起,还没有录入航班信息!!\n");

}

//*********

void InquireInf(){    

       char str[4];

       int opt;

 

       //clrscr();>>>>>>  

       if(Pn!=0)

       {

              printf("请输入 1.航班号  2.抵达城市 0.退出\n");

              gets(str);opt=atoi(str);

              while(opt!=3)

              {    

                     if(opt==1) 

                            {  printf("请输入航班号:\n");

                               Inquire();

                            }

                     else if(opt==2)

                            {  printf("请输入抵达城市:\n");

                               Inquire();

                            }

                     else printf("无效的输入命令,请再输入:\n");

 

                     printf("退出?[3] 继续?[1.航班号 2.抵达城市]:\n");

                     gets(str);opt=atoi(str);

              }//end of while 

       //clrscr();>>>>>>

       BookFace();

       }else printf("空文件,没有任何数据信息!!请载入!!!\n");//end of if1

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -