#include <iostream>

#include <string>                            //包含字符串函数处理头文件;

#define N 10000

using namespace std;


struct air                                  //定义结构体数组;

{

  int num;

  int count;

  char start[20];

  char over[20];

  char time[20];

  char name[20];

  char ID[20];

}s[N];

int i,m=0;

#define  PRINT  s[i].num,s[i].start,s[i].over,s[i].time,s[i].count    //定义输出格式;

void input( );                             //输入航班信息;

void print( );                             //输出航班信息;

void search( );                            //查找航班信息;

void dingpiao( );                          //订票信息;

void shanchu( );                           //删除航班信息;

void tuipiao( );                           //退票信息;

void xiugai( );                            //修改信息;

void main( )

{

       int j;

    cout<<"1.输入航班信息\n";

    cout<<"2.浏览航班信息\n";

    cout<<"3.修改航班信息\n";

    cout<<"4.查找航班信息\n";
    cout<<"5.删除航班信息\n";
    cout<<"6.订票信息\n";

    cout<<"7.退票信息\n";

    cout<<"0.退出\n";
    cout<<"=====================================================\n";

    cout<<"请在0-7中选择服务种类以回车键结束:\n";

    cin>>j;

                   cout<<"2.按航线删除\n";

                cout<<"0.返回\n";

                cout<<"请在0-2中选择以回车键结束:\n";

                  cin>>n;                                      //读取删除方式;

              if(n==0)

                        break;

                 switch(n)

                       {

                 case 1:

                    cout<<"请输入航班号:\n";

                     cin>>no;                                //读取航班号;

                 read();                                   //调用读取函数;

                  break;                                    //跳出循环;

                 case 2:

                    cout<<"请输入起始站名称:\n";

                 cin>>name1;

                    cout<<"请输入终点站名称:\n";

                 cin>>name2;

                read();                                    //调用读取函数;

                break;

                       }

               for(i=0;i<m;i++)

                        {

                    if(s[i].num==no||strcmp(s[i].start,name1)==0&&strcmp(s[i].over,name1)==0)

                                             //判断输入的信息是否存在;

        {

             s[i]=s[m-1];

             m--;

        }

               }

      cout<<"查找结束或不存在这个信息"<<endl;

      cout<<"是否继续删除"<<endl;

      cout<<"请输入yes或no以回车键结束"<<endl;

      cin>>ii;                                   //读取是否继续信息;

      save();

      if(strcmp(ii,"yes")==0);                       //是否继续删除;

      cout<<"请按任意键或是回车键结束返回上层的菜单\n";

      break;

               }while(n!=1&&n!=2&&n!=3&&n!=4&&n!=0);       //判断结束;

        }

else

cout<<"密码错误!您不是管理员,不能使用此项功能!谢谢再见!"<<endl;

}

void dingpiao()                            //订票函数;

{

       int n;

       char a[10];

       do

       {

              search();                          //调用查询函数;

              cout<<"请输入您要订的机票书以回车键结束:"<<endl;

       cin>>n;                             //输入所订的机票数;

              if(n<0)

              {

                     cout<<"请输入有效的机票数!"<<endl;    //判断机票数是否出错;

                     cout<<endl;

break;

              }

              if(s[i].count!=0&&s[i].count>=n)     //判断是否出错;

              {

s[i].count=s[i].count-n;

save();                                       //调用保存函数;

cout<<"订票成功!";

break;

              }

if(s[i].count<n)                              //判断是否出错;

{

       cout<<"是否继续? 请输入yes或no以回车键结束:"<<endl; //是否继续订票;

       cin>>a;

}while(!strcmp(a,"yes"));

       }

       void tuipiao()                              //退票函数;

       {

              int n;

    char a[10];           

       do

       {

              search();                            //调用查询函数;

              cout<<"请输入您要退的机票数目:"<<endl;

         cin>>n;                                 //输入所退票数;

s[i].count=s[i].count+n;                       //判断票数是否有效;

cout<<"退票成功!\n";

cout<<"是否继续?  请输入yes或no以回车键结束:\n"; //是否继续退票;

cin>>a;

       }while(!strcmp(a,"yes"));

       getchar();

       }

       void xiugai();                             //修改函数;

       {

              struct                                 //定义结构体;

              {

                     int no;

                     char name1[20];

                     char name2[20];

char time[20];

int count;

}x[1];

char j[10];

char f[]="jifangzhi";                     //设密码;

int n;

cout<<"请输入密码并以回车键结束:\n";
cin>>f;

if(strcmp(f,"jifangzhi")==0)

{

       read();

       do

       {

          cout<<"请选择修改方式:\n"

                "*1,按航班号修改:\n"

                "*2,按航线修改:\n";

          cout<<"请在1与2中修改以回车键结束:\n";

          cin>>n;

        switch(n)

        {

          case 1:cout<<"请输入航班号:\n";

                     cin>>x[0].no;

                     break;

          case 2:cout<<"请输入起始站:\n";

               cin>>x[0].name1;

          case 3:cout<<"请输入终点站:\n";

            cin>>x[0].name2;

                     break;

              }

              for(i=0;i<m;i++)

              {

                     if(strcmp(s[i].over,x[0].name1)==0&&strcmp(s[i].over,x[0].name2)==0

                     {

                            cout<<"航班号     起始站      终点站      时间     机票数\n";

                            cout<<PRINT;

                            break;                                                      

                     }


                     if(s[i].num==x[0].no)               //判断输出条件;

                     {

                            cout<<"航班号     起始站      终点站      时间     机票数\n";

                cout<<PRINT;

                            break;

                     }

              }

    x[0].no=0;                             //将结构体中的号设为0;

       cout<<"请输入新的航班号,起始站,终点站,时间(星期几),机票数\n";

cin>>x[0].no>>x[0].name1>>x[0].name2>>x[0].time>>x[0].count;

s[i].num==x[0].no;

strcpy(s[i].start,x[0].name1);

strcpy(s[i].over,x[0].name2);

strcpy(s[i].time,x[0].time);

s[i].count=x[0].count;

save();                                       //调用保存函数;

cout<<"是否继续? 请输入yes或no以回车键结束:\n";
cin>>j;

       }while(strcmp(j,"yes")==0);                   //判断结束;

}

else

cout<<"密码错误!您不是管理员,不能使用此项功能!谢谢再见!\n";

}
                             

 

 

 

 

 

  

 

 

  

 

  


[fly]机票订购系统[/fly]