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

📄 新建 文本文档.txt

📁 ,这个系统是我在大2的时候自己编写的。感觉还可以。也许有-,C-C++,交通/航空行业/transportation applications
💻 TXT
📖 第 1 页 / 共 2 页
字号:

#include <iostream.h>
#include <process.h>
#include <string.h>
#include <conio.h>
#include <stdio.h>
#include <iomanip.h>
#define MAX 50
#define NULL 0
typedef struct Customer                //已定票乘客信息
{
   char Name[7];                    //姓名
   int Amount;                    //定票数
   char Rank;                        //舱位等级
   int Seat_No;                    //座位号
   struct Customer *Next;
}Customer;

typedef struct Replace                //替补乘客信息
{
   char Name[7];                    //姓名
   int Amount;                    //定票数
   char Rank;                        //舱位等级
   char Seat_No;                    //座位号
   struct Replace *Next;
}Replace,*PReplace;   
 
typedef struct Flight                //航线信息
{
   char Des_Name[10];                //终点站名
   char Flight_No[6];                //航班号
   char Plane_No[6];                //飞机号
   char Week_Day;                    //飞行周日
   int Customer_Amount;            //乘员定额
   int Free_Amount;                //剩余票数
   float Price[3];                //舱位等级的价格
   Replace *ReplName;                //该航班的候补乘客名单
   Customer *CustName;                //该航班的已定票乘客名单
   struct Flight *Next;            //指示下一航线结点
}Flight,*PFlight;
int Customer_Count=0;                //所有航线的定票乘客总数
Flight *Head;                        //航线头指针
Flight *p2;                        //航线结点指针
Customer *Custp1[MAX];                //各条航线乘客结点指针
Replace *Replp1[MAX];                //各条航线候补结点指针
int IsEmpty=1;                        //是否有定票乘客
int IsReplace=1;                    //是否有候补乘客
Customer *prior;                    //满足要求的定票乘客的前结点,以作删除操作


//-------密码登入窗口函数----------
int Code_Verify()
{
   char b[10];    
   char c[10]="ygnmf";//已经进行简单加密
   char a;          
   int i=0,j,k=1,x;
   while(1)
   {
       system("cls");
       cout<<"\n\n\n\n\n\n\n\n\n\t\t\t请输入系统密码:";
       for(j=0;j<i;j++)
           cout<<"●";
       cout<<endl;
       a=getch();
       if(int(a)!=8||int(a)!=13)//不等于回车或退格键
           b=a-1;
       if(int(a)==8)
       {
           i-=2;
           system("cls");
           cout<<"\n\n\n\n\n\n\n\n\n\t\t\t请输入系统密码:";
           for(j=0;j<i;j++)
               cout<<"●";
           cout<<endl;
       }
       if(int(a)==13)
       {
           b='\0';
           if(strcmp(c,b)==0)
               return 0;
           else
           {
               if(k==3)
               {
                   while (!kbhit()) 
                   {
                       system("cls");
                       for(x=0;x<100000000;x++);
                   cout<<"\n\n\n\n\n\n\n\n\t\t 你无权使用本系统,任意键退出系统..."<<endl;
                   for(x=0;x<100000000;x++);}
                   return 1;
               }
               cout<<"\n\t\t   密码错误,你还有"<<3-k<<"次机会.请重新输入."<<endl;
               k++;
               getch();
           }
           i=-1;
       }
       i++;
   }
}
//-------启动画面函数----------
void Cover()    
{    
   char line[]={"━━━━━━━━━━"};
   char bar[]={"...."};
   int i,j,k=0,x=0,y=0;    
   for(i=1;i<=strlen(line)/2;)
   {
       system("cls");
       for(j=0;j<9;j++)   //改变行坐标
           cout<<endl;
       for(j=0;j<(75-strlen(line))/2;j++) //改变列坐标
           cout<<" ";
       for(j=1;j<=i;j++)            //进度显示器
           cout<<"■";
       for(x=strlen(line)/2;x>i;x--)
           cout<<"□";
       if(k==4)
           i++;
       cout<<endl;    
       for(j=0;j<(75-strlen(line))/2;j++)    //行坐标定位
           cout<<" ";
       cout<<line;            //输出线条
       cout<<endl;
       for(j=0;j<(65-strlen(bar))/2;j++)
           cout<<" ";
       cout<<(i-1)*10<<"% Loading";
       cout.write(bar,k);
       cout<<endl;
       for(j=0;j<10;j++)
           cout<<endl;
       for(j=0;j<24;j++)
           cout<<" ";
       cout<<"程序设计:03软件工程(9)班---狂龙闪客"<<endl;
       for(j=0;j<24;j++)
           cout<<" ";
       for(j=0;j<=12;j++)
           cout<<"─";
       cout<<endl;
       for(j=0;j<10000000;j++);//延时效果
       k++;
       if(k>4)
           k=0;
   }
}
//---------------菜单模板函数---------------
char ModelMenu(char *s[],int Itemcount)
{
       int i;
       char answer;
       system("cls");
       cout<<"\n\n";
       cout<<"\t\t\t┌──────────────┐"<<endl;
       cout<<"\t\t\t"<<s[0]<<endl;
       cout<<"\t\t\t├──────────────┤"<<endl;
       cout<<"\t\t\t│              │"<<endl;
       cout<<"\t\t\t│ ┌──────────┐ │"<<endl;
       for(i=1;i<Itemcount;i++)
       {
           cout<<"\t\t\t"<<s<<endl;
           if(i+1!=Itemcount)
       cout<<"\t\t\t│ ├──────────┤ │"<<endl;
       }
       cout<<"\t\t\t│ └──────────┘ │"<<endl;
       cout<<"\t\t\t└──────────────┘"<<endl;    
       cout<<"\t\t\t 请输入菜单项前的操作代码:";
       cin>>answer;
       return answer;
}
//---------------主菜单函数---------------
char MainMenu()
{
   char *MenuItem[]={"│  航空客运订票系统菜单  │","│ │[1]. 航 线 管 理 │ │",\
       "│ │[2]. 订 票 办 理 │ │","│ │[3]. 退 票 办 理 │ │","│ │[4]. 乘 客 管 理 │ │",\
   "│ │[5]. 系 统 离 开 │ │"};
   return ModelMenu(MenuItem,6);
}
//---------------是否继续函数---------------
char Continue() 
{
   int i;
   char answer;
   while(1)
   {    
       cout<<"\t\t   ";
       for(i=0;i<15;i++)
           cout<<"─";
       cout<<"\n\t\t\t   是否继续(Y/N)?";
       cin>>answer;
       if(answer=='y'||answer=='Y')
           return 'y';
       else if(answer=='n'||answer=='N')
           return 'n';
       else
               cout<<"\t\t\t 输入错误,请重新输入!"<<endl;
   }
}
//---------------操作出错函数---------------
void ErrorMess()
{
   cout<<"\n\t\t\t对不起,没有相关菜单项,按任意键继续..."<<endl;
   getch();
}
//-----------------系统退出-----------------
int ExitSystem()
{
   char answer;
   cout<<"\n\t\t\t 你确定是否真要离开系统吗(Y/N)?";
   cin>>answer;
   if(answer=='y'||answer=='Y')
       return 1;
   else
       return 0;
}
//--------------操作提示函数-------------
void prefix(char *Item)
{
   int i;    
   system("cls");
   cout<<"\n\n\t\t\t 当前操作:"<<Item<<endl;
   cout<<"\t\t   ";
   for(i=0;i<15;i++)
       cout<<"─";
   cout<<endl;
}
//--------------航线查找函数-------------
//Find_Line()为重载函数
int Find_Line(PFlight L,char *key)//引用调用
{
   int flag=0;   //该标志位0表示未找到相关信息,反之即找到,以下标志位同理
   Flight *p1;
   p1=L;            //赋航线首地址
   if(p1==p2)        //首航线不作比较
       return flag;
   while(p1!=p2&&p1!=NULL)    //本航班号不纳入比较范围,否则会一直提示航线不唯一
   {
       if(strcmp(p1->Flight_No,key)==0)
       {
           flag=1;
           break;
       }
       p1=p1->Next;//指向下一航班结点
   }
       return flag;
}
int Find_Line(PFlight L,char *key,PFlight &p2,int &Flight_No)//引用调用
{
   int flag=0;   //该标志位0表示未找到相关信息,反之即找到
   Flight *p1;
   p1=L;            //赋航线首结点
   while(p1!=NULL)    
   {
       if(strcmp(p1->Flight_No,key)==0)//不包括当前航线
       {
           flag=1;
           p2=p1;
           break;
       }
       p1=p1->Next;                    //指向下一航班结点
       if(p1!=NULL)                //遇结束符不作统计范围
           Flight_No++;
   }
   return flag;
}
//-----------------航线添加函数-------------
void Line_Add()
{
   Flight *p1;    //建立临时航线结点
   while(1)
   {
       if(Head==NULL)//航线为空
       {
           p1=p2=new Flight;    //建立首个航线
           Head=p2;
       }
       else
       {
           p1=new Flight; //建立航线结点
           p2->Next=p1;   //前一航线结点指向当前航班结点
           p2=p1;           //保留当前航班结点地址    
       }
       prefix("航线增设");
       cout<<"\t\t\t   请输入终点站名:";
       cin>>p2->Des_Name;   
       while(1)            //数据合法性检验
       {
           cout<<"\n\t\t\t   请输入航班号(唯一):";
           cin>>p2->Flight_No;
           if(Find_Line(Head,p2->Flight_No))   //存在航班号
               cout<<"\n\t\t\t   输入的航班号不唯一!"<<endl;
           else
               break;
       }
       cout<<"\n\t\t\t   请输入飞机号:";
       cin>>p2->Plane_No;
       while(1)
       {
           cout<<"\n\t\t\t   请输入飞行周日(1-7):";
           cin>>p2->Week_Day; 
           if(p2->Week_Day<'1'||p2->Week_Day>'7')
           {    
               cout<<"\n\t\t   数据输入错误,按任意键继续输入."<<endl;
               getch();
           }
           else
               break;
       }
       cout<<"\n\t\t\t   请输入乘员定额:";
       cin>>p2->Customer_Amount;
       cout<<"\n\t\t\t   请输入头等舱票价:";
       cin>>p2->Price[0];
       cout<<"\n\t\t\t   请输入普通舱票价:";
       cin>>p2->Price[1];
       cout<<"\n\t\t\t   请输入经济舱票价:";
       cin>>p2->Price[2];
       p2->Free_Amount=p2->Customer_Amount;     //剩余票数与乘员定额相同
       p2->CustName=NULL;                         //该航线定票乘客头指针为空
       p2->ReplName=NULL;                         //初始候补名单为空 
       if(Continue()=='n')
       {
           p2->Next=NULL;                         //航线的下一结点为空
           return;
       }
   }
}
//------------航线是否为空函数-------------
int Empty_Flight()
{
   if(Head==NULL)
   {
       system("cls");
       cout<<"\n\n\n\n\n\n\n\n\t\t   对不起,没有相关航线。按任意键返回..."<<endl;
       getch();
       return 1;
   }
   else
       return 0;
}
//------------航线查看函数-----------------
void Line_See()
{
   int Day;
   Flight *p1;
   p1=Head;
   char *Week_Day[]={"星期一","星期二","星期三","星期四","星期五","星期六","星期日"};
   if(Empty_Flight())    //航班线为空
       return;
   prefix("航班查看");
   cout<<" ┌────┬───┬───┬────┬────┬────┬────────┐"<<endl;
   cout<<" │     │     │     │     │     │     │   票   价   │"<<endl;
   cout<<" │终点站名│航班号│飞机号│飞行周日│乘员定额│剩余票数├──┬──┬──┤"<<endl;
   cout<<" │    │   │   │    │    │    │头舱│普舱│经舱│"<<endl;
   cout<<" ├────┼───┼───┼────┼────┼────┼──┼──┼──┤"<<endl;
   while(p1!=NULL)
   {
       Day=p1->Week_Day-'0'-1;//数字转换相应星期数 
       cout<<" │"<<setiosflags(ios::left)<<setw(8)<<p1->Des_Name<<"│"<<setw(6)<<p1->Flight_No<<\
       "│"<<setw(6)<<p1->Plane_No<<    "│"<<setw(8)<<Week_Day[Day]<<    "│   "<<setw(5)<<p1->Customer_Amount<<\
       "│   "<<setw(5)<<p1->Free_Amount<<"│"<<setw(4)<<p1->Price[0]<<"│"<<setw(4)<<p1->Price[1]<<"│"<<setw(4)<<p1->Price[2]<<"│"<<endl;
       p1=p1->Next; 
       if(p1!=NULL)
               cout<<" ├────┼───┼───┼────┼────┼────┼──┼──┼──┤"<<endl;
   }
   cout<<" └────┴───┴───┴────┴────┴────┴──┴──┴──┘"<<endl;
   cout<<"\n\t\t\t   按任意键返回子菜单..."<<endl;
   getch();
}
void Sub1Menu()
{
   char *MenuItem[]={"│   航空客运航线管理子菜单   │","│ │[1]. 航 线 增 设 │ │",\
       "│ │[2]. 航 线 查 看 │ │","│ │[3]. 返 回 主 菜 单 │ │"};
   while(1)
       switch(ModelMenu(MenuItem,4))
       {
           case '1':{Line_Add();break;}
           case '2':{Line_See();break;}
           case '3':{return;}
           default:{ErrorMess();}
       }
}
//---------------订票办理函数---------------
void Sub2Menu()
{
   int Ticket_Count,Seat_No,i,flag=0;
   int Flight_No=0;        //记录满足条件的航线的定票结点
   Flight *p1;                //记下满足条件的航线结点地址
   Customer *p2;            //临时性定票乘员结点
   Replace *p3;            //临时性候补乘员结点
   char answer[7];            //用户输入的航班数据
   char temp;
   int tag=0;                //候补乘客标志位
   int Amount;
   int IsRepl=0;            //是否执行候补操作标志位
   if(Empty_Flight())        //航班线为空
       return;
   while(1)

⌨️ 快捷键说明

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