亚洲激情专区-91九色丨porny丨老师-久久久久久久女国产乱让韩-国产精品午夜小视频观看

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

C語言如何實現航空訂票系統

發布時間:2022-03-15 10:12:19 來源:億速云 閱讀:148 作者:iii 欄目:開發技術

本篇內容介紹了“C語言如何實現航空訂票系統”的有關知識,在實際案例的操作過程中,不少人都會遇到這樣的困境,接下來就讓小編帶領大家學習一下如何處理這些情況吧!希望大家仔細閱讀,能夠學有所成!

利用二進制將一整個結構體中的數據存入文件,然后讀取文件時再用二進制的形式將結構體中的數據讀取出來,邊讀取邊創建鏈表,將結構體中的數據保存到鏈表中。

如果有第一次寫這種大作業不知道如何下手,但又不想直接復制粘貼,想搞清楚這個代碼的原理的可以私信我,畢竟我當時也第一次寫這種大作業時也很苦惱(我當時寫的要是有這么完整的代碼該多好啊,我直接就是復制粘貼運行看效果)

// author:吳澤琛
// nylg
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <string.h>
#include <conio.h>
#include <iostream>
#define PRINTF "%s\t\t%d\t\t%s\t\t\t%s\t\t星期%d\t\t\t%d\n",airlinep->airlinenum,airlinep->airplanenum,airlinep->dep,airlinep->des,airlinep->time,airlinep->ticks
using namespace std;
typedef class mange
{
    public:
    char mangername[20];
    char scert[20];
    char securityscert[20];
    class mange *next;
}manger;
typedef class use
{
    public:
//    char userairlinenum[20];//航班號
//    int userairplanenum;//飛機號 
//    char userdes;//目的地 
//    char userdep;//出發時間 
//    int usertime;//起飛時間 
    int ticks;//票數 
    int bookcnt;//訂票次數 
    char username[20];
    char scert[20];
    char securityscert[20];
    char bookticks[2000][2000];//機票名字 
    class use *next;
}user;
typedef class airline
{
    public:
    char airlinenum[20];//航班號
    int airplanenum;//飛機號
    char dep[1000];//出發地點
    char des[1000];//目的地
    int time;//飛行時間(星期幾)
    int ticks;//票數
    class airline *next;
}airline;

manger* mhead = NULL, *mend = NULL;
user *uhead = NULL, *uend = NULL;
airline *ahead = NULL, *aend = NULL;
airline *ahead1 = (airline*)malloc(sizeof(airline));
int mcnt, ucnt, acnt;
char mscert[200] = {"wsgly"};

void load();
void main1();
void changemenu();
void mainmenu();
void Registermenu();
void Loginmenu();
void mlmenu();
void ulmenu();
void Login();
void Register();
void uRegister();
void mRegister();
void mLogin();
void uLogin();
void userfunction();
void search();
void searchmenu();
void printairline();
void printdes();
void printtime();
void printticks();
void airlinesort();
void dessort();
void bookticks(user *userp);
void returnticks(user *userp);
void findairline(user *userp); 
void mangerfunction();
void deleteusernum(char *airlinenum);
void addairline();
void deletenum();
void changeairline();
void searchuser();
void changeuserairline(char *userbookticks, char *bookticks);
void rmanger(manger *mhead);
void rairline(airline *ahead);
void ruser(user *uhead);
void readmangerfile();
void readuserfile();
void readairlinefile();
void title();
void date();
void cls();
void over();
void writefile(int flag);
int exist(char *name, int flag);
void hualihushao1();
void hualihushao2();
void searchscert();
void searchmangerscert();
void searchuserscert();
void changescert();
void changemangerscert();
void changeuserscert();
void print_message();

int main()
{
    //hualihushao1();
    system("color F6");
    title();
    mhead = (manger*)malloc(sizeof(manger));
    uhead = (user*)malloc(sizeof(user));
    ahead = (airline*)malloc(sizeof(airline));
    ahead1->next = ahead;
    
    ruser(uhead);
    rmanger(mhead);
    rairline(ahead);
    //                            test
//    user *q = uhead;
//    while (q)
//    {
//        printf("%d %s %s %d %s\n",q->ticks,q->username,q->scert,q->bookcnt,q->securityscert);
//        q = q->next;
//    }
    airline *p = ahead;
    while (p)
    {
        printf("%s %d %s %s %d %d\n",p->airlinenum,p->airplanenum,p->dep,p->des,p->time,p->ticks);
        p = p->next;
    }
    main1();
    return 0;
}
void main1()
{
    int choose;
    int sign;
    
    while (1)
    {
        cls();
        date();
        mainmenu();
    
        char choose = getch(); 
        switch(choose)
        {
            case '1':
                    cls();
                    Login();
                    break;
            case '2':
                    cls();
                    Register(); 
                    break;
            case '3':
                    cls();
                    searchscert();
                    break;
            case '4':
                    cls();
                    changescert();
                    break;
            case '5':
                    cls();
                    over();
                    cls();
                    break;
            default :
                    printf("輸入無效!");
                    break;
        }
    }
    
}
void Login() 
{
    int sign;
    while (1)
    {
        cls();
        date();
        Loginmenu();
        char choose = getch();
    switch(choose)
    {
        case '1':
                cls();
                mLogin();
                break;
        case '2':
                cls();
                uLogin(); 
                break;
        case '3':
                sign = 1;
                break;
        case '4':
                cls();
                over();
                break;
        default :
                printf("輸入無效!");
                break;
                
                
    }
        if (sign)
        {
            break;
        }
    }
    
}
void Register()
{
    int sign;
    
    while (1)
    {
        cls();
        date();
        Registermenu();
        char choose = getch();
    switch(choose)
    {
        case '1':
                cls();
                mRegister();
                break;
        case '2':
                cls();
                uRegister();
                break;
        case '3':
                sign = 1;
                cls();
                break;
        case '4':
                cls();
                over();
                cls();
                break;
        default :
                printf("輸入無效!");
                break;
    }
    if (sign)
    {
        break;
    }
    }
    
}

void userfunction(user *userp)
{    
    int sign;
    
    while (1)
    {
        cls();
        date();
    ulmenu();
    char choose = getch();
    switch(choose)
    {
        case '1':
                cls();
                bookticks(userp);
                break;
        case '2':
                cls();
                returnticks(userp);
                break;
        case '3':
                cls();
                findairline(userp);
                break;
        case '4':
                cls();
                search();
                break;
        case '5':
                sign = 1;
                cls();
                break;
        case '6':
                cls();
                over();
                cls();
                break;
        default :
                printf("輸入無效!");
                break;
    }
        if (sign)
        {
            break;
        }
    }
    
}

void mangerfunction()
{
    int sign = 0;
    int choose ;
    while (1)
    {
        cls();
        date();
    mlmenu();
    char choose = getch();
    switch(choose)
    {
        case '1':
                cls();
                addairline();
                break;
        case '2':
                cls();
                deletenum();
                break;
        case '3':
                cls();
                changeairline();
                break;
        case '4':
                cls();
                searchuser();
                break;
        case '5':
                cls();
                search();
                break;
        case '6':
                sign = 1;
                cls();
                break;
        case '7':
                cls();
                over();
                cls();
                break;
        default :
                printf("輸入無效!");
                break;
    }
        if (sign)
        {
            break;
        }
    }
    
}
void mlmenu()
{
    printf("                                                 管理員頁面\n");
    printf("                              **************************************************\n");
    printf("                              **               1.增加航班信息                 **\n"); 
    printf("                              **                                              **\n");
    printf("                              **               2.刪除航班信息                 **\n");
    printf("                              **                                              **\n");
    printf("                              **               3.修改航班信息                 **\n");
    printf("                              **                                              **\n");
    printf("                              **               4.查看客戶信息                 **\n");
    printf("                              **                                              **\n");
    printf("                              **               5.瀏覽航班信息                 **\n");
    printf("                              **                                              **\n");
    printf("                              **               6.返回                         **\n");
    printf("                              **                                              **\n");    
    printf("                              **               7.退出                         **\n");
    printf("                              **************************************************\n");
    printf("請按鍵選擇:");
}

void ulmenu()
{
    printf("                                                  乘客頁面\n");
    printf("                              **************************************************\n");
    printf("                              **               1.訂票                         **\n"); 
    printf("                              **                                              **\n");
    printf("                              **               2.退票                         **\n");
    printf("                              **                                              **\n");
    printf("                              **               3.查看已訂機票                 **\n");
    printf("                              **                                              **\n");
    printf("                              **               4.瀏覽航班信息                 **\n");
    printf("                              **                                              **\n");
    printf("                              **               5.返回                         **\n");
    printf("                              **                                              **\n");
    printf("                              **               6.退出                         **\n");
    printf("                              **************************************************\n");
    printf("請按鍵選擇:");
}

void mainmenu()
{
    printf("\n\n");
    printf("                                        歡 迎 使 用 航 空 管 理 系 統 !\n");
    printf("                              **************************************************\n");
    printf("                              **                    1.登錄                    **\n");
    printf("                              **                                              **\n");
    printf("                              **                    2.注冊                    **\n");
    printf("                              **                                              **\n");
    printf("                              **                    3.找回密碼                **\n");
    printf("                              **                                              **\n");
    printf("                              **                    4.修改密碼                **\n");
    printf("                              **                                              **\n");
    printf("                              **                    5.退出                    **\n");
    printf("                              **************************************************\n");
    printf("請按鍵選擇:");
}

void Registermenu()
{
    printf("                                                   注冊頁面\n");
    printf("                              **************************************************\n");
    printf("                              **                 1.管理員注冊                 **\n");
    printf("                              **                                              **\n");
    printf("                              **                 2.乘客注冊                   **\n");
    printf("                              **                                              **\n");
    printf("                              **                 3.返回                       **\n");
    printf("                              **                                              **\n");
    printf("                              **                 4.退出                       **\n");
    printf("                              **************************************************\n");
    printf("請按鍵選擇:");
}

void Loginmenu()
{
    printf("                                                   登錄頁面\n");
    printf("                              **************************************************\n");
    printf("                              **                 1.管理員登錄                 **\n");
    printf("                              **                                              **\n");
    printf("                              **                 2.用戶登錄                   **\n");
    printf("                              **                                              **\n");
    printf("                              **                 3.返回                       **\n");
    printf("                              **                                              **\n");
    printf("                              **                 4.退出                       **\n");
    printf("                              **************************************************\n");
    printf("請按鍵選擇:");
}

void changemenu()
{
        printf("\n\n");
        printf("\t\t\t\t*******************************\n");
        printf("\t\t\t\t**      1.修改航班號         **\n");
        printf("\t\t\t\t**                           **\n");
        printf("\t\t\t\t**      2.修改飛機號         **\n");
        printf("\t\t\t\t**                           **\n");
        printf("\t\t\t\t**      3.修改出發地點       **\n");
        printf("\t\t\t\t**                           **\n");
        printf("\t\t\t\t**      4.修改目的地         **\n");
        printf("\t\t\t\t**                           **\n");
        printf("\t\t\t\t**      5.修改起飛時間       **\n");
        printf("\t\t\t\t**                           **\n");
        printf("\t\t\t\t**      6.修改票數           **\n");
        printf("\t\t\t\t**                           **\n");
        printf("\t\t\t\t**      7.返回               **\n");
        printf("\t\t\t\t*******************************");
        printf("\n\n");
}
void searchmenu()
{
    printf("\n\n\n\n");
    printf("\t\t\t\t***********************************\n");
    printf("\t\t\t\t**         1.查看航班信息        **\n");
    printf("\t\t\t\t**                               **\n");
    printf("\t\t\t\t**         2.按航班號瀏覽        **\n");
    printf("\t\t\t\t**                               **\n");
    printf("\t\t\t\t**         3.按起飛時間瀏覽      **\n");
    printf("\t\t\t\t**                               **\n");
    printf("\t\t\t\t**         4.按機票數瀏覽        **\n");
    printf("\t\t\t\t**                               **\n");
    printf("\t\t\t\t**         5.返回                **\n");
    printf("\t\t\t\t**                               **\n");
    printf("\t\t\t\t**         6.退出                **\n");
    printf("\t\t\t\t***********************************\n");
    printf("請按鍵選擇:");
}

void ruser(user *uhead)
{
    FILE *fp;
    fp = fopen("user","a+");
    ucnt = fread(uhead,sizeof(user),1,fp);
    fclose(fp);
    uend = uhead;
    readuserfile();
}
void rmanger(manger *mhead)
{
    FILE *fp;
    fp = fopen("manger","a+");
    mcnt = fread(mhead,sizeof(manger),1,fp);
    fclose(fp);
    mend = mhead;
    readmangerfile();
}
void rairline(airline *ahead)
{
    FILE *fp;
    fp = fopen("airline","a+");
    acnt = fread(ahead,sizeof(airline),1,fp);
    fclose(fp);
    aend = ahead;
    readairlinefile();
}
void uRegister()
{
    date();
    user *p;
    char username[1000];
    char scert[1000];
    char securityscert[2000];
    FILE *fp;

    if (ucnt == 0)          //第一次添加
    {
        printf("\n\n\n\n\n\n\n");
        printf("-------------請輸入賬戶(按0退出):");
        while (gets(username))
        {
            if (strcmp(username,"0") == 0)
            {
                return ;
            }
            if (strlen(username) <= 16 && !exist(username, 0))
                break;
            else if (exist(username, 0))
            {
                printf("-------------該賬戶已存在!請重新輸入(按0退出):");
            }
            else
            {
                printf("-------------請輸入長度為1到16位的賬戶:");
            }
        }
        strcpy(uhead->username, username);
        printf("-------------請輸入密碼:");
        while (gets(scert))
        {
            if (strlen(scert) <= 16)
                break;
            else
                printf("-------------請輸入長度為1到16的密碼:");
        }
        strcpy(uhead->scert, scert);
        printf("-------------請輸入您的密保:");
        while (gets(securityscert))
        {
            if (strlen(securityscert) <= 16)
            {
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的密保:");
            }
        }
        strcpy(uhead->securityscert,securityscert);
        uhead->bookcnt = 0;
        uend = uhead;
        uend->next = NULL;
 
    }
    else
    {
        p = (user*)malloc(sizeof(user));
        printf("\n\n\n\n\n\n\n");
        printf("-------------請輸入賬戶(按0退出):");
        while (gets(username))
        {
            if (strcmp(username,"0") == 0)
            {
                return ;
            }
            if (strlen(username) <= 16 && !exist(username, 0))
                break;
            else if (exist(username, 0))
            {
                printf("-------------該賬戶已存在!請重新輸入(按0退出):");
            }
            else
            {
                printf("-------------請輸入長度為1到16位的賬戶:");
            }
        }
        strcpy(p->username, username);
        printf("-------------請輸入密碼:");        
        while (gets(scert))
        {
            if (strlen(scert) <= 16)
                break;
            else
                printf("-------------請輸入長度為1到16的密碼:");
        }
        strcpy(p->scert, scert);
        printf("-------------請輸入您的密保:");
        while (gets(securityscert))
        {
            if (strlen(securityscert) <= 16)
            {
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的密保:");
            }
        }
        strcpy(p->securityscert,securityscert);
        p->bookcnt = 0;
        uend->next = p;
        uend = p;
        uend->next = NULL;
    }
    ucnt++;
    writefile(0);
    cls();
        printf("\n\n\n\n\n\n\n");
        printf("\t\t\t\t\t*******************************\n"); 
        printf("\t\t\t\t\t**                           **\n");
        printf("\t\t\t\t\t       乘客%s創建成功!                                      \n",uend->username);
        printf("\t\t\t\t\t**     即將跳轉至主頁面...   **\n");
        printf("\t\t\t\t\t**                           **\n");
        printf("\t\t\t\t\t*******************************\n");
    Sleep(3000);
}

int exist(char *name, int flag)//1 為存在   0 為不存在 
{
    if (flag == 0)
    {
        user *p = uhead;
        while (p != NULL && ucnt != 0)
        {
            if (strcmp(name,p->username) == 0)
            {
                return 1;
            }
            p = p->next;
        }
    }
    else if (flag == 1)
    {
        manger *p = mhead;
        while (p != NULL)
        {
            if (strcmp(name,p->mangername) == 0)
            {
                return 1;
            }
            p = p->next; 
        }
    }
    return 0;
}

void uLogin() 
{
    date();
    int cnt = 4;
    int flag = 0;
    int k = 0;
    int i;
    char c;
    user *p = uhead;
    char username[2000];
    char scert[2000];
    printf("\n\n\n\n\n\n\n");
    FILE *fp;
    fp = fopen("user","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無乘客賬號信息!!\n-------------請先前往注冊!");
        getchar();
        return ;
    }
    
    printf("-------------請輸入您的賬戶(按0退出):");
//    gets(username);
//    getch(); 
    while (gets(username))
    {
        if (strcmp(username,"0") == 0)
        {
            return ;
        } 
        if (strlen(username) <= 16)
        {
            break;
        } else 
        {
            printf("-------------請輸入長度為1到16位的賬戶:");
        }
    }
    printf("-------------請輸入您的密碼(按0退出):");
//    gets(scert
        for (i = 0; (c = getch()) != '\r';)
        {
            if (c == '0')
            {
                return ;
            }
            if (i <= 15 && isprint(c))
            {
                scert[i] = c;
                i ++;
                k ++;
                printf("*");
            }
            if ( k > 0 && c > 0 && c == '\b')
            {
                i --;
                k --;
                printf("\b");
                printf(" ");
                printf("\b");
            }
        }
    scert[i] = '\0';
    printf("\n");
    while (p != NULL)
    {
        if (strcmp(p->username,username) == 0)
        {
            flag = 1;
            while (strcmp(p->scert,scert) != 0)
            {
                cnt --;
                if (cnt == 1)
                {
                    cls();
                    printf("\n\n\n\n\n\n\n");
                    printf("-------------密碼輸入次數已用完!\n-------------即將退出登錄頁面...");
                    Sleep(3000);
                    cls();
                    return ;
                }
                printf("-------------密碼錯誤!您還有%d次機會!\n",cnt - 1);
                printf("-------------請重新輸入:"); 
                gets(scert);
            }
            printf("-------------乘客%s登錄成功!\n-------------即將跳轉至乘客頁面...",p->username);
            Sleep(3000);
            cls();
            userfunction(p);
        }
        p = p->next;
    }
    if (flag == 0)
    {
        printf("-------------不存在此賬號!\n-------------請先前往注冊!\n");
        printf("-------------即將跳轉至主頁面...");
        Sleep(2000);
    }
}

void mLogin()
{
    date();
    int cnt = 4;
    int flag = 0;
    int k = 0;
    int i;
    char c;
    manger *p = mhead;
    char mangername[2000];
    char scert[2000];
    printf("\n\n\n\n\n\n\n");
    FILE *fp;
    fp = fopen("manger","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無管理員賬號信息!!\n-------------請先前往注冊!");
        getchar();
        return ; 
    }
    printf("-------------請輸入您的賬戶(按0退出):");
    while (gets(mangername))
    {
        if (strcmp(mangername,"0") == 0)
        {
            return ;
        }
        if (strlen(mangername) <= 16)
        {
            break;
        } else 
        {
            printf("-------------請輸入長度為1到16位的賬戶:");
        }
    }
    
    printf("-------------請輸入您的密碼(按0退出):");
    for (i = 0; (c = getch()) != '\r';)
    {
        if (c == '0')
        {
            return ;
        }
        if (i <= 15 && isprint(c))
        {
            scert[i] = c;
            i ++;
            k ++;
            printf("*");
        }
        if ( k > 0 && c > 0 && c == '\b')
        {
            i --;
            k --;
            printf("\b");
            printf(" ");
            printf("\b");
        }
    }
    scert[i] = '\0';
    printf("\n");
    
    while (p)
    {
        if (strcmp(p->mangername,mangername) == 0)
        {
            
            flag = 1;
            while (strcmp(p->scert,scert) != 0)
            {
                cnt --;
                if (cnt == 1)
                {
                    cls();
                    printf("\n\n\n\n\n\n\n");
                    printf("-------------密碼輸入次數已用完!\n-------------即將退出登錄頁面...");
                    Sleep(3000);
                    cls();
                    return ;
                }
                printf("-------------密碼錯誤!您還有%d次機會!\n",cnt - 1);
                printf("-------------請重新輸入:"); 
//                gets(scert);
for (i = 0; (c = getch()) != '\r';)
    {
        if (c == '0')
        {
            return ;
        }
        if (i <= 15 && isprint(c))
        {
            scert[i] = c;
            i ++;
            k ++;
            printf("*");
        }
        if ( k > 0 && c > 0 && c == '\b')
        {
            i --;
            k --;
            printf("\b");
            printf(" ");
            printf("\b");
        }
    }
    scert[i] = '\0';
    printf("\n");
            }
            printf("-------------管理員%s登錄成功!\n-------------即將跳轉至管理員頁面...",p->mangername);
//            load();
            //cls();
            mangerfunction();
            return ;
        }
        p = p->next;
    }
    if (flag == 0)
    {
        printf("-------------不存在此賬號!\n-------------請先前往注冊!\n");
        printf("-------------即將跳轉至主頁面...");
        Sleep(2000);
    }
}

void mRegister()
{
    date();
    FILE *fp;
    char mangerscert[1000];
    char mname[1000];
    char scert[1000];
    char securityscert[2000];
    printf("\n\n\n\n\n\n\n");
    printf("-------------請輸入管理員驗證碼:");
//    getchar();
    gets(mangerscert);
    int cnt = 2;
    while (--cnt >= 0)
    {
        if (strcmp(mangerscert,mscert) == 0)
        {
            printf("-------------管理員驗證成功!!\n-------------即將進入注冊頁面...");
            Sleep(1000);
            cls();
            break;
        } else 
        {
            printf("-------------管理員驗證失敗!!\n-------------您還有%d次機會!!\n",cnt + 1);
            printf("-------------請重新輸入:");
            gets(mangerscert);
        }
        if (cnt == 0)
        {
            printf("-------------輸入次數已用完!!\n-------------即將退出管理員注冊系統...");
            Sleep(2000);
            cls();
            return ;
        }
    }

    manger *p;
    if (mcnt == 0)
    {
        printf("\n\n\n\n\n\n\n");
        printf("-------------請輸入賬戶(按0退出):");
        while (gets(mname))
        {
            if (strcmp(mname,"0") == 0)
            {
                return ;
            }
            if (strlen(mname) <= 16 )
            {
                break;
            } else
            {
                printf("-------------請輸入長度為1到16位的賬戶:");
            }
        }
        strcpy(mhead->mangername,mname);
        printf("-------------請輸入密碼:");
        while (gets(scert))
        {
            if (strlen(scert) <= 16)
            {
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位密碼:");
            }
        }
        strcpy(mhead->scert,scert);
        printf("-------------請輸入您的密保:");
        while (gets(securityscert))
        {
            if (strlen(securityscert) <= 16)
            {
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的密保:");
            }
        }
        strcpy(mhead->securityscert,securityscert);
        mend = mhead;
        mend->next = NULL;
    }
    else 
    {
        p = (manger*)malloc(sizeof(manger));
        printf("\n\n\n\n\n\n\n");
        printf("-------------請輸入賬戶(按0退出):");
        while (gets(mname))
        {
            if (strcmp(mname,"0") == 0)
            {
                return ;
            } 
            if (strlen(mname) <= 16 && !exist(mname,1))
            {
                break;
            }
            else if (exist(mname,1))
            {
                printf("-------------該賬戶已存在!請重新輸入!(按0退出)"); 
            } else
            {
                printf("-------------請輸入長度為1到16位的賬戶:");
            }
        }
        strcpy(p->mangername,mname);
        printf("-------------請輸入密碼:");
        while (gets(scert))
        {
            if (strlen(scert) <= 16)
            {
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的密碼:");
            }
        }
        strcpy(p->scert,scert);
        printf("-------------請輸入您的密保:");
        while (gets(securityscert))
        {
            if (strlen(securityscert) <= 16)
            {
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的密保:");
            }
        }
        strcpy(p->securityscert,securityscert);
        mend->next = p;
        mend = p;
        mend->next = NULL;
    }
    mcnt ++;
    
    writefile(1);
    cls();
        printf("\n\n\n\n\n\n\n");
        printf("\t\t\t\t\t*******************************\n"); 
        printf("\t\t\t\t\t**                           **\n");
        printf("\t\t\t\t\t       管理員%s創建成功!      \n",mend->mangername);
        printf("\t\t\t\t\t**     即將跳轉至主頁面...   **\n");
        printf("\t\t\t\t\t**                           **\n");
        printf("\t\t\t\t\t*******************************\n");
    Sleep(3000);
}
void title()
{
    system("color F2");
    system("title **************************************************************************歡迎使用航空訂票系統****************************************************************************"); 
}
void date()
{
    system("date/t");
    system("time/t");
}

void cls()
{
    system("cls");
}

void over()
{
    //hualihushao2();
    cls();
    system("color 6");
    int time = 6;
    printf("\n\n\n\n\n\n\n\n\n");
    printf("\t\t\t\t\t\t感謝您的使用!!\n\n\n\n\n");
    printf(" 程序即將關閉...");
    while (--time >= 1)
    {
        printf("\r%d",time);
        printf("\b");
        Sleep(1000);
    }
    cls();
    exit(0);
    
}
void readuserfile()
{
    user *p = uhead;
    FILE *fp = fopen("user","ab+");
    while (fread(p,sizeof(user),1,fp))
    {
        if (p->next != NULL)
        {
            p = (user*)malloc(sizeof(user));
            uend->next = p;
            uend = p;
            uend->next = NULL;
        }
    }
}
void readmangerfile()
{
    manger *p;
    FILE *fp;
 
    p = mhead;
    fp = fopen("manger", "ab+");
    while (fread(p, sizeof(manger), 1, fp))
    {
        if (p->next != NULL)
        {
            p = (manger*)malloc(sizeof(manger));
 
            mend->next = p;
            mend = p;
            mend->next = NULL;
        }
    }
}
void readairlinefile()
{
    airline *p;
    FILE *fp;
    
    p = ahead;
    fp = fopen("airline","ab+");
    while (fread(p,sizeof(airline),1,fp))
    {
        if(p->next != NULL)
        {
            p = (airline*)malloc(sizeof(airline));
            aend->next = p;
            aend = p;
            aend->next = NULL;
        }
    }
}
void addairline()
{
    FILE *fp;
    airline *p;
    char airlinenum[2000];
    if (acnt == 0)
    {
        printf("-------------請輸入航班號(按0返回):");
//        getchar();
        while (gets(airlinenum))
        {
            if (strcmp(airlinenum,"0") == 0)
            {
                return ;
            }
            if (strlen(airlinenum) <= 16)
            {
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的航班號:");
            }
        }
        strcpy(ahead->airlinenum,airlinenum);
        printf("-------------請輸入飛機號:");
//        getchar();
        long long int airplanenum;
        while (scanf("%lld",&airplanenum))
        {
            if (airplanenum <= 0)
            {
                printf("-------------請輸入正確格式的飛機號:");
            } else if (airplanenum > 999999)
            {
                printf("-------------請輸入長度為1-6位的飛機號:");
            } else
            {
                ahead->airplanenum = airplanenum;
                break;
            }
        }
        printf("-------------請輸入出發地點:");
        getchar();
        char dep[1000];
        while (gets(dep))
        {
            if (strlen(dep) <= 16)
            {
                strcpy(ahead->dep,dep);
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的出發地點:");
            }
        }
//        getchar();
        printf("-------------請輸入目的地:");
        
        char des[1000];
        while (gets(des))
        {
            if (strlen(des) <= 16)
            {
                strcpy(ahead->des,des);
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的目的地:");
            }
        };
        printf("-------------請輸入機票數:");
        int ticks;
        while (scanf("%d",&ticks))
        {
            if (ticks <= 0)
            {
                printf("-------------請輸入正確格式的機票數!");
            } else if (ticks > 999)
            {
                printf("-------------請輸入0-999以內的機票數!");
            } else 
            {
                ahead->ticks = ticks;
                break;
            }
        }
        int time;
        printf("-------------請輸入起飛時間(1-7):");
        while (scanf("%d",&time))
        {
            if (time < 1 || time > 7)
            {
                printf("-------------請輸入正確的起飛時間(周一到周日用1-7表示):");
            } else 
            {
                ahead->time = time;
                break;
            }
             
        }
        aend = ahead;
        aend->next = NULL;
    } else
    {
        printf("-------------請輸入航班號(按0返回):");
        getchar();
        while (gets(airlinenum))
        {
            if (strcmp(airlinenum,"0") == 0)
            {
                return ;
            }
            if (strlen(airlinenum) <= 16)
            {
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的航班號:");
            }
        }
        int flag = 0;
        p = ahead;
        while (p)
        {
            if (strcmp(p->airlinenum,airlinenum) == 0)
            {
                flag = 1;
                break;
            }
            p = p->next;
        }
        if(flag == 1)
        {
            int ticks;
            printf("-------------請輸入要增加票的數量:");
            while (scanf("%d",&ticks))
            {
                if (ticks <= 0)
                {
                    printf("-------------請輸入正確格式的機票數!");
                } else if (ticks > 999)
                {
                    printf("-------------請輸入0-999以內的機票數!");
                } else 
                {
                    p->ticks += ticks;
                    printf("-------------航班號%s票數添加成功!",p->airlinenum);
                    break;
                }
            }
        } else
        {
        p = (airline*)malloc(sizeof(airline));
        strcpy(p->airlinenum,airlinenum);
        printf("-------------請輸入飛機號:");
        long long int airplanenum;
        while (scanf("%lld",&airplanenum))
        {
            if (airplanenum <= 0)
            {
                printf("-------------請輸入正確格式的飛機號:");
            } else if (airplanenum > 999999)
            {
                printf("-------------請輸入長度為1-6位的飛機號:");
            } else 
            {
                p->airplanenum = airplanenum;
                break;
            }
        }
        printf("-------------請輸入出發地點:");
        getchar();
        char dep[1000];
        while (gets(dep))
        {
            if (strlen(dep) <= 16)
            {
                strcpy(p->dep,dep);
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的出發地點:");
            }
        }
        
        printf("-------------請輸入目的地:");
        char des[1000];
        while (gets(des))
        {
            if (strlen(des) <= 16)
            {
                strcpy(p->des,des);
                break;
            } else 
            {
                printf("-------------請輸入長度為1到16位的目的地:");
            }
        }
        printf("-------------請輸入機票數:");
        int ticks;
        while (scanf("%d",&ticks))
        {
            if (ticks < 0)
            {
                printf("-------------請輸入正確格式的機票數!");
            } else if (ticks > 999)
            {
                printf("-------------請輸入0-999以內的機票數!");
            } else 
            {
                p->ticks = ticks; 
                break;
            }
        }
        int time;
        printf("-------------請輸入起飛時間(1-7):");
        while (scanf("%d",&time))
        {
            if (time < 1 || time > 7)
            {
                printf("-------------請輸入正確的起飛時間(周一到周日用1-7表示):");
            } else 
            {
                p->time = time;
                break;
            } 
        }
        getchar();
        aend->next = p;
        aend = p;
        aend->next = NULL; 
        }
    }
    acnt ++;
    writefile(2);
    cls();
    printf("\n\n\n\n\n\n");
    printf("\t\t\t\t\t********************************\n");
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t       航班號%s添加成功!       \n",aend->airlinenum);
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t********************************\n");
    printf("頁面即將跳轉...");
    Sleep(2000);
    
}
void writefile(int flag)// 0 寫用戶 1 寫管理員 2 寫航班 
{
    user *userp = uhead;
    manger *mangerp = mhead;
    airline *airlinep = ahead;
    FILE *fp;
    
    if (flag == 0)
    {
        fp = fopen("user","w");
        while (userp)
        {
            fwrite(userp,sizeof(user),1,fp);
            userp = userp->next;
        }
    } else if(flag == 1)
    {
        fp = fopen("manger","w");
        while (mangerp)
        {
            fwrite(mangerp,sizeof(manger),1,fp);
            mangerp = mangerp->next;
        }
    } else if(flag == 2)
    {
        fp = fopen("airline","w");
        while (airlinep)
        {
            fwrite(airlinep,sizeof(airline),1,fp);
            airlinep = airlinep->next;
        }
    }
    fclose(fp);
}
void deletenum()
{
    airline *p, *sign;
    p = ahead;
    char airlinenum[1000];
    int flag = 0;
    
    FILE *fp;
    fp = fopen("airline","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("\n\n\n\n\n\n\n");
        printf("-------------暫無航班信息!!");
        getchar();
        printf("pause");
        return ;
    }
    
    printf("-------------請輸入您要刪除的航班號(按0退出):");
    while (scanf("%s",airlinenum))
    {
        if (strcmp("0",airlinenum) == 0)
        {
            getchar();
            return ;
        }
        while (p)
        {
            if (strcmp(p->airlinenum,airlinenum) == 0)
            {
                flag = 1;
                break;
            }
            p = p->next;
        }
        if (flag == 0)
        {
            printf("-------------查無此航班!");
            printf("請重新輸入(按0退出):");
            p = ahead;
        } else 
        {
            break;
        }
    }
    deleteusernum(airlinenum);
    p = ahead;
    if (strcmp(ahead->airlinenum,airlinenum) == 0)
    {
        sign = ahead;
        strcpy(sign->airlinenum,ahead->airlinenum);
        ahead = ahead->next;
        ahead1->next = ahead;
    }
    while (p->next != NULL)
    {
        if (strcmp(p->next->airlinenum,airlinenum) == 0)
        {
            sign = p->next;
            strcpy(sign->airlinenum,p->next->airlinenum);
            p->next = p->next->next;
            break;
        }
        p = p->next;
    } 
    getchar();
    printf("\n\n\n\n\n\n");
    printf("-------------航班號%s刪除成功!\n",sign->airlinenum);
    printf("-------------頁面即將跳轉...");
    Sleep(1000);
//    free(sign);
    writefile(2);
}

void deleteusernum(char *airlinenum)
{
    user *userp = uhead;
    int flag;
    
    while (userp)
    {
        flag = 1;
        for (int i = 0; i < userp->bookcnt; i ++)
        {
            if (strcmp(userp->bookticks[i],airlinenum) == 0)
            {
                flag = i;
                break;
            }
        }
        if (flag != 1)
        {
            for (int j = flag; j < userp->bookcnt - 1; j ++)
            {
                strcpy(userp->bookticks[j],userp->bookticks[j + 1]);
            }
            userp->bookcnt --;
        }
        userp = userp->next;
    }
    writefile(0);
}
void changeairline()
{
    airline *airlinep = ahead1->next;
    char airlinenum[2000];
    int airplanenum, time, ticks;
    char dep[2000], des[2000];
    int exist = 0;
    int flag = 0;
    
    
    printf("\n\n\n\n\n\n");
    FILE *fp;
    fp = fopen("airline","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("\n\n\n\n\n\n\n");
        printf("-------------暫無航班信息!!");
        getchar();
        getchar();
        return ;
    }
    printf("航班號\t\t飛機號\t\t出發地點\t\t目的地\t\t出發時間\t\t票數\n");
    while (airlinep)
    {
        printf(PRINTF);
        airlinep = airlinep->next;
    }
    airlinep = ahead;
    printf("-------------請輸入您要修改的航班號(按0返回):");
//    getchar();
    while (gets(airlinenum))
    {
        if (strcmp("0",airlinenum) == 0)
        {
            return ;
        }
        while (airlinep)
        {
            if (strcmp(airlinep->airlinenum,airlinenum) == 0)
            {
                exist = 1;
                break;
            }
            airlinep = airlinep->next;
        }
        if (!exist)
        {
            airlinep = ahead;
            printf("-------------未查詢到該航班!請重新輸入:");
        } else 
        {
            break;
        }
    }
    if (!exist)
    {
        return ;
    } else 
    {
        int  choose ;
        cls();
        changemenu();
        while (1)
        {
            printf("-------------請輸入您要進行的操作:");
            scanf("%d",&choose);
            switch(choose)
            {
                case 1:
                        printf("-------------請輸入修改后的航班號:");
                        scanf("%s",airlinenum);
                        changeuserairline(airlinep->airlinenum,airlinenum);
                        strcpy(airlinep->airlinenum,airlinenum);
                        break;
                case 2:
                        printf("-------------請輸入修改后的飛機號:");
                        scanf("%lld",&airplanenum);
                        airlinep->airplanenum = airplanenum;
                        break;
                case 3:
                        printf("-------------請輸入修改后的出發地點:");
                        scanf("%s",dep);
                        strcpy(airlinep->dep,dep);
                        break;
                case 4:
                        printf("-------------請輸入修改后的目的地:");
                        scanf("%s",des);
                        strcpy(airlinep->des,des);
                        break;
                case 5:
                        printf("-------------請輸入修改后的起飛時間:");
                        while (scanf("%d",&time))
                        {
                            if (time < 1 || time > 7)
                        {
                            printf("-------------請輸入正確的起飛時間(周一到周日用1-7表示):");
                        } else 
                        {
                            airlinep->time = time;
                            break;
                        }
             
                        }
                        break;
                case 6:
                        printf("-------------請輸入修改后的機票數:");
                        while (scanf("%d",&ticks))
                        {
                            if (ticks <= 0)
                            {
                                printf("-------------請輸入正確格式的機票數!");
                            } else if (ticks > 999)
                        {
                            printf("-------------請輸入0-999以內的機票數!");
                            } else 
                            {
                                airlinep->ticks = ticks;
                                break;
                            }
                        }
                        break;
                case 7:
                        flag = 1;
                        break;
            }
            if (flag)
            {
                break;
            }
        }
    }
    writefile(2);
}
void changeuserairline(char *userbookticks, char *bookticks)
{
    user *userp = uhead;
    while (userp)
    {
        for (int i = 0; i < userp->bookcnt; i ++)
        {
            if (strcmp(userp->bookticks[i],userbookticks) == 0)
            {
                strcpy(userp->bookticks[i],bookticks);
            }
        }
        userp = userp->next;
    }
    writefile(0);
}
void searchuser()
{
    user *userp = uhead;
    char username[2000];
    int flag = 0;
    
    printf("-------------請輸入您要查詢的乘客名(按0退出):");
    gets(username);
    if (strcmp(username,"0") == 0)
        {
            return ;
        } 
    while (userp)
    {
        if (strcmp(userp->username,username) == 0)
        {
            flag = 1;
            break;
        }
        userp = userp->next;
    }
    if (!flag)
    {
        cls();
        printf("\n\n\n\n\n\n\n");
        printf("\t\t\t\t\t*******************************\n"); 
        printf("\t\t\t\t\t**                           **\n");
        printf("\t\t\t\t\t**     不存在該乘客信息!    **\n");
        printf("\t\t\t\t\t**     即將跳轉至上一頁面... **\n");
        printf("\t\t\t\t\t**                           **\n");
        printf("\t\t\t\t\t*******************************\n");
        Sleep(2000);
        return ; 
    } else 
    {
        long long int sign;
        while (1)
        {
            cls();
            printf("\n\n");
            printf("\t\t\t\t\t  乘客%s的個人信息\n",userp->username);
            printf("\t\t\t\t***********************************\n");
            printf("\t\t\t\t           乘客賬號:");
            puts(userp->username);
            printf("\t\t\t\t**                               **\n");
            printf("\t\t\t\t           乘客密碼:");
            puts(userp->scert);
            printf("\t\t\t\t**                               **\n");
            printf("\t\t\t\t           訂票次數:");
            printf("%d\n",userp->bookcnt);
            printf("\t\t\t\t**                               **\n");
            if (userp->bookcnt)
            {
                printf("\t\t\t\t           訂票航班號:");
                for (int i = 0; i < userp->bookcnt; i ++) 
                {
                    printf("%s ",userp->bookticks[i]);
                }
                printf("\n");
                printf("\t\t\t\t**                               **\n");
            } else
            {
                printf("\t\t\t             此乘客還未預訂任何航班!\n");
            }
            printf("請輸入0返回上一頁面!");
            while (scanf("%lld",&sign))
            {
                if (sign == 0)
                {
                    return ;
                } else 
                {
                    printf("無效的輸入!請重新輸入:");
                }
            }
             
        }
    }
}

void bookticks(user *userp)
{
    char airlinenum[2000];
    airline *airlinep = ahead1->next;
    
    int exist = 0;
    int sign = 1;
    
    printf("\n\n\n\n\n\n");

    FILE *fp;
    fp = fopen("airline","r"); 
    char ch;
    ch =  fgetc(fp);
    if (ch == EOF)
    {
        printf("-------------暫無航班信息!!");
        getchar();
        return ;
    }
    printf("航班號\t\t飛機號\t\t出發地點\t\t目的地\t\t出發時間\t\t票數\n");
    while (airlinep)
    {
        printf(PRINTF);
        airlinep = airlinep->next;
    }
    printf("-------------請輸入您要預訂的航班號(按0退出):");
    getchar();
    gets(airlinenum);
    airlinep = ahead;
    if (strcmp("0",airlinenum) == 0)
        {
            return ;
        }
    while (airlinep)
    {
        
        if (strcmp(airlinep->airlinenum,airlinenum) == 0)
        {
            if (airlinep->ticks == 0)
            {
                printf("-------------此航班無余票!\n");
                sign = 0;
            } else
            {
                int n;
                printf("-------------請輸入要預訂的機票數量:");
                while (scanf("%d",&n))
                {
                    if (airlinep->ticks < n)
                    {
                        printf("-------------機票數量不夠!請重新輸入:");
                    } else if (airlinep->ticks >= n)
                    {
                        userp->ticks += n; 
                        airlinep->ticks -= n;
                        break;
                    }
                }
                userp->bookcnt ++;
                strcpy(userp->bookticks[userp->bookcnt - 1],airlinenum);
//                userp->usertime = airlinep->time;
                writefile(0);
                writefile(2);
                exist = 1;
                break;
            }
        }
        airlinep = airlinep->next;
    }
    if (exist == 0 && sign == 1)
    {
        printf("-------------不存在此航班!\n");
    } else if (exist == 1)
    {
        printf("-------------航班%s訂票成功!\n",airlinep->airlinenum);
    }
    printf("-------------頁面即將跳轉...");
    Sleep(2000);
}
void returnticks(user *userp)
{
    airline *airlinep = ahead;
    char airlinenum[2000];
    int exist = 0;
    int flag = 0;
    int cnt = userp->bookcnt;
    if (cnt == 0)
    {
        printf("\n\n\n\n\n\n\n");
        printf("\t\t\t\t\t\t您還未預訂任何航班!");
        getchar();
        return ;
    }
    
    printf("\n\n\n\n\n\n");
    
    for (int i = 0; i < cnt; i ++)
    {
        printf("-------------第%d次預訂的航班號:",i + 1);
        printf("%s\n",userp->bookticks[i]);
    }
    printf("-------------請輸入要退還機票的航班號(按0退出):");
    
    getchar();
    while (gets(airlinenum))
    {
        if (strcmp(airlinenum,"0") == 0)
        {
            return ;
        }
        for (int i = 0; i < userp->bookcnt; i ++)
        {
            if (strcmp(airlinenum,userp->bookticks[i]) == 0)
            {
                flag = i;
                exist = 1;
                break;
            }
        }
        if (!exist)
        {
            printf("-------------為查詢到該航班號!\n");
            printf("-------------請重新輸入航班號(按0退出):");
        } else 
        {
            break;
        }
    }
    int n;
    while (airlinep)
    {
        if (strcmp(airlinep->airlinenum,airlinenum) == 0)
        {
            printf("-------------請輸入要退訂票數量:");
            while (scanf("%d",&n))
            {
                if (userp->ticks < n)
                {
                    printf("-------------您未持有此數量票量!\n");
                    printf("-------------請重新輸入:");
                } else if (userp->ticks >= n)
                {
                    userp->ticks -= n;
                    airlinep->ticks += n;
                    break;
                }
            }
        }
        airlinep = airlinep->next;
    }
    
    if (userp->ticks == 0)
    {
        for (int i = flag; i < userp->bookcnt - 1; i ++)
        {
            strcpy(userp->bookticks[i],userp->bookticks[i + 1]);
        }
            userp->bookcnt --;
    }

    writefile(0);
    writefile(2);
    printf("-------------%s號航班退票成功!\n",userp->bookticks[flag]);
    printf("-------------即將返回上一頁面...");
    Sleep(2000);
}
void findairline(user *userp)
{
    int cnt = userp->bookcnt;
    long long  sign;
    if (cnt == 0)
    {
        printf("\n\n\n\n\n\n\n");
        printf("\t\t\t\t\t\t您還未預訂任何航班!\n");
    }
    printf("\n\n\n\n\n\n");

    
    for (int i = 0; i < cnt; i ++)
    {
        printf("\t\t\t\t\t\t第%d次預訂的航班號:%s\t第%d預定航班的票數:%d\n",i + 1, userp->bookticks[i], i+1, userp->ticks);
    }
    printf("\n\n請輸入0退出:");
    while (scanf("%lld",&sign))
    {
        if (sign == 0)
        {
            break;
        } else
        {
            printf("-------------無效的輸入!請重新輸入!");
        }
    }
}
void search()
{
    int sign;
    while (1)
    {
        cls();
        date();
        searchmenu();
        char choose = getch();
        switch(choose)
        {
            case '1':
                    cls();
                    print_message();
                    break;
            case '2':
                    cls();
                    printairline();
                    break;
            case '3':
                    cls();
                    printtime();
                    break;
            case '4':
                    cls();
                    printticks();
                    break; 
            case '5':
                    cls();
                    sign = 1;
                    break;
            case '6':
                    cls();
                    over();
                    cls();
            default :
                    break;
        }
        if (sign)
        {
            break;
        }
    }
}

void airlinesort()
{
    airline *f, *x, *y, *p;
    f = NULL;
    if (ahead1->next == NULL || ahead1->next->next == NULL)
    {
        return ;
    }
    while (f != ahead1->next->next)
    {
        for (p = ahead1; p->next->next != f; p = p->next)
        {
            if (strcmp(p->next->airlinenum,p->next->next->airlinenum) > 0)
            {
                x = p->next;
                y = p->next->next;
                p->next = y;
                x->next = y->next;
                y->next = x;
            }
        }
        f = p->next;
    }
    return ;
}


void timesort()
{
    airline *f, *x, *y, *p;
    f = NULL;
    if (ahead1->next == NULL || ahead1->next->next == NULL)
    {
        return ;
    }
    while (f != ahead1->next->next)
    {
        for (p = ahead1; p->next->next != f; p = p->next)
        {
            if (p->next->time > p->next->next->time)
            {
                x = p->next;
                y = p->next->next;
                p->next = y;
                x->next = y->next;
                y->next = x;
            }
        }
        f = p->next;
    }
    return ;
}
void tickssort()
{
    airline *f, *x, *y, *p;
    f = NULL;
    if (ahead1->next == NULL || ahead1->next->next == NULL)
    {
        return ;
    }
    while (f != ahead1->next->next)
    {
        for (p = ahead1; p->next->next != f; p = p->next)
        {
            if (p->next->ticks > p->next->next->ticks)
            {
                x = p->next;
                y = p->next->next;
                p->next = y;
                x->next = y->next;
                y->next = x;
            }
        }
        f = p->next;
    }
    return ;
}
void printairline()
{
    date();
    airlinesort();
    airline *airlinep = ahead1->next;
    printf("\n\n\n\n\n\n");
    FILE *fp;
    fp = fopen("airline","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無航班信息!!");
        getchar();
        return ;
    }

    printf("航班號\t\t飛機號\t\t出發地點\t\t目的地\t\t出發時間\t\t票數\n");
    while (airlinep)
    {
        printf(PRINTF);
        airlinep = airlinep->next;
    }
    system("pause");
}

void printticks()
{
    date();
    tickssort();
    airline *airlinep = ahead1->next;
    printf("\n\n\n\n\n\n");
    FILE *fp;
    fp = fopen("airline","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無航班信息!!");
        getchar();
        return ;
    }
    printf("航班號\t\t飛機號\t\t出發地點\t\t目的地\t\t出發時間\t\t票數\n");
    while (airlinep)
    {
//        printf("666\n");
        printf(PRINTF);
        airlinep = airlinep->next;
    }
    system("pause");
}
void printtime()
{
    date();
    timesort();
    airline *airlinep = ahead1->next;
    printf("\n\n\n\n\n\n");
    FILE *fp;
    fp = fopen("airline","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無航班信息!!");
        getchar();
        return ;
    }
    printf("航班號\t\t飛機號\t\t出發地點\t\t目的地\t\t出發時間\t\t票數\n");
    while (airlinep)
    {
        printf(PRINTF);
        airlinep = airlinep->next;
    }
    system("pause");
}
void searchscert()
{
    printf("\n\n\n\n\n\n");
    printf("\t\t\t\t\t********************************\n");
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t**      1.管理員找回密碼      **\n");
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t**      2.乘客找回密碼        **\n");
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t**      3.返回                **\n");
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t********************************\n");
    printf("請按鍵選擇:");
    int sign = 0;
    char choose = getch();
    while (1)
    {
        cls();
        
        switch (choose)
        {
            case '1':
                    cls();
                     searchmangerscert();
                     sign = 1;
                    break;
            case '2':
                    cls();
                    searchuserscert();
                    sign = 1;
                    break;
            case '3':
                    sign = 1;
                    break;
            default :
                    printf("輸入無效!");
                    break;
        }
        if (sign)
        {
            break;
        }
    }
}
void searchmangerscert()
{
    date();
    manger *p = mhead;
    char mangername[2000];
    int flag = 0;
    int sign = 0;
    printf("\n\n\n\n\n\n\n");
    FILE *fp;
    fp = fopen("manger","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無管理員賬號!!\n-------------請先前往注冊!");
        getchar();
        return ;
    }
    printf("-------------請輸入您的賬號(按0退出):");
//    getchar();
    while (gets(mangername))
    {
        if (strcmp(mangername,"0") == 0)
        {
            return ;
        }
        while (p)
        {
            if (strcmp(p->mangername,mangername) == 0)
            {
                flag = 1;
                break;
            }
            p = p->next; 
        }
        if (flag)
        {
            break;
        } else
        {
            printf("-------------此賬號不存在!請重新輸入(按0退出):");
            p = mhead;
        }
    }
    if (flag)
    {
        p = mhead;
        char securityscert[2000];
        printf("-------------請輸入您設置的密保(按0退出):");
        while (gets(securityscert))
        {
            if (strcmp(securityscert,"0") == 0)
            {
                return ;
            }
            while (p)
            {
                if (strcmp(p->securityscert,securityscert) == 0)
                {
                    sign = 1;
                    break;
                }
                p = p->next;
            }
            if (sign)
            {
                printf("-------------密保輸入正確!\n");
                printf("-------------您的密碼為%s\n",p->scert);
                getchar();
                return ;
            } else 
            {
                printf("-------------密保輸入錯誤!請重新輸入(按0退出):");
                p = mhead;
            }
        }
    }
}
void searchuserscert()
{
    date();
    user *p = uhead;
    char username[2000];
    int flag = 0;
    int sign = 0;
    printf("\n\n\n\n\n\n\n");
    FILE *fp;
    fp = fopen("user","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無乘客賬號!!\n-------------請先前往注冊!");
        getchar();
        return ;
    }
    printf("-------------請輸入您的賬號(按0退出):");
//    getchar();
    while (gets(username))
    {
        if (strcmp(username,"0") == 0)
        {
            return ;
        }
        while (p)
        {
            if (strcmp(p->username,username) == 0)
            {
                flag = 1;
                break;
            }
            p = p->next; 
        }
        if (flag)
        {
            break;
        } else
        {
            printf("-------------此賬號不存在!請重新輸入(按0退出):");
            p = uhead;
        }
    }
    if (flag)
    {
        p = uhead;
        char securityscert[2000];
        printf("-------------請輸入您設置的密保(按0退出):");
        while (gets(securityscert))
        {
            if (strcmp(securityscert,"0") == 0)
            {
                return ;
            }
            while (p)
            {
                if (strcmp(p->securityscert,securityscert) == 0)
                {
                    sign = 1;
                    break;
                }
                p = p->next;
            }
            if (sign)
            {
                printf("-------------密保輸入正確!\n");
                printf("-------------您的密碼為%s\n",p->scert);
                getchar();
                return ;
            } else 
            {
                printf("-------------密保輸入錯誤!請重新輸入(按0退出):");
                p = uhead;
            }
        }
    }
}
void changescert()
{
    printf("\n\n\n\n\n\n");
    printf("\t\t\t\t\t********************************\n");
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t**      1.管理員修改密碼      **\n");
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t**      2.乘客修改密碼        **\n");
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t**      3.返回                **\n");
    printf("\t\t\t\t\t**                            **\n");
    printf("\t\t\t\t\t********************************\n");
    printf("請按鍵選擇:");
    char choose = getch();
    int sign = 0; 
    while (1)
    {
        cls();
        switch (choose)
        {
            case '1':
                    cls();
                     changemangerscert();
                     sign = 1;
                    break;
            case '2':
                    cls();
                    changeuserscert();
                    sign = 1;
                    break;
            case '3':
                    sign = 1;
                    break;
            default :
                    printf("輸入無效!");
                    break;
        }
        if (sign)
        {
            break;
        }
    }
}
void changemangerscert()
{
    date();
    manger *p = mhead;
    char mangername[2000];
    char scert[2000];
    int flag = 0;
    int sign = 0;
    char securityscert[2000];
    FILE *fp;
    fp = fopen("manger","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無管理員賬號信息!!\n-------------請先前往注冊!");
        getchar();
        return ; 
    }
    printf("\n\n\n\n\n\n\n");
    printf("-------------請輸入您的賬號(按0退出):");
    while (gets(mangername))
    {
        if (strcmp(mangername,"0") == 0)
        {
            return ;
        }
        while (p)
        {
            if (strcmp(p->mangername,mangername) == 0)
            {
                flag = 1;
                break;
            }
            p = p->next; 
        }
        if (flag)
        {
            break;
        } else
        {
            printf("-------------此賬號不存在!請重新輸入:");
            p = mhead;
        }
    }
    if (flag)
    {
        p = mhead;
        printf("-------------請輸入您設置的密保(按0退出):");
        while (gets(securityscert))
        {
            if (strcmp(securityscert,"0") == 0)
            {
                return ;
            }
            while (p)
            {
                if (strcmp(p->securityscert,securityscert) == 0)
                {
                    sign = 1;
                    break;
                }
                p = p->next;
            }
            if (sign)
            {
                printf("-------------請輸入修改后的密碼(按0退出):");
                while (gets(scert))
                {
                    if (strcmp(scert,"0") == 0)
                    {
                        return ;
                    } 
                    if (strlen(scert) <= 16)
                    {
                        break;
                    } else 
                    {
                        printf("-------------請輸入1到16位的密碼:");
                    }
                }
                strcpy(p->scert,scert);
                printf("-------------密碼修改成功!");
                writefile(1);
                getchar();
                return ;
            } else 
            {
                printf("-------------密保輸入錯誤!請重新輸入:");
                p = mhead;
            }
        }
    }
}
void changeuserscert()
{
    date();
    user *p = uhead;
    char username[2000];
    char scert[2000];
    char securityscert[2000];
    int flag = 0;
    int sign = 0;
    FILE *fp;
    fp = fopen("user","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無管理員賬號信息!!\n-------------請先前往注冊!");
        getchar();
        return ; 
    }
    printf("\n\n\n\n\n\n\n");
    printf("-------------請輸入您的賬號(按0退出):");
    while (gets(username))
    {
        if (strcmp(username,"0") == 0)
        {
            return ;
        }
        while (p)
        {
            if (strcmp(p->username,username) == 0)
            {
                flag = 1;
                break;
            }
            p = p->next; 
        }
        if (flag)
        {
            break;
        } else
        {
            printf("-------------此賬號不存在!請重新輸入:");
            p = uhead;
        }
    }
    if (flag)
    {
        p = uhead;
        printf("-------------請輸入您設置的密保(按0退出):");
        while (gets(securityscert))
        {
            if (strcmp(securityscert,"0") == 0)
            {
                return ;
            }
            while (p)
            {
                if (strcmp(p->securityscert,securityscert) == 0)
                {
                    sign = 1;
                    break;
                }
                p = p->next;
            }
            if (sign)
            {
                printf("-------------請輸入修改后的密碼(按0退出):");
                while (gets(scert))
                {
                    if (strcmp(scert,"0") == 0)
                    {
                        return ;
                    } 
                    if (strlen(scert) <= 16)
                    {
                        break;
                    } else 
                    {
                        printf("-------------請輸入1到16位的密碼:");
                    }
                }
                strcpy(p->scert,scert);
                printf("-------------密碼修改成功!");
                writefile(0);
                getchar();
                return ;
            } else 
            {
                printf("-------------密保輸入錯誤!請重新輸入:");
                p = uhead;
            }
        }
    }
}

void print_message()
{
    date();
    airline *airlinep = ahead1->next;
    printf("\n\n\n\n\n\n");
    FILE *fp;
    fp = fopen("airline","r");
    char ch;
    ch = fgetc(fp);
    rewind(fp);
    if (ch == EOF)
    {
        printf("-------------暫無航班信息!!");
        getchar();
        return ;
    }
    printf("航班號\t\t飛機號\t\t出發地點\t\t目的地\t\t出發時間\t\t票數\n");
    while (airlinep)
    {
//        printf("666\n");
        printf(PRINTF);
        airlinep = airlinep->next;
    }
    system("pause");
}

void hualihushao1()
{
    printf("\n\n\n\n\n\n\n\n\n\n\n\n");
    printf("\t\t\t\t\t\t即將進入訂票系統...");
    system("color 40");
    Sleep(250);
    system("color 04");
    Sleep(250);
    system("color 60");
    Sleep(250);
    system("color 24");
    Sleep(250);
    system("color AF");
    Sleep(250);
    system("color 92");
    Sleep(250);
    system("color 57");
    Sleep(250);
    system("color F4");
    Sleep(250);
    system("color F4");
    Sleep(250);
}
void hualihushao2()
{
    printf("\n\n\n\n\n\n\n\n\n\n\n\n");
    printf("\t\t\t\t\t\t訂票系統即將關閉...");
    system("color 40");
    Sleep(250);
    system("color 04");
    Sleep(250);
    system("color 60");
    Sleep(250);
    system("color 24");
    Sleep(250);
    system("color AF");
    Sleep(250);
    system("color 92");
    Sleep(250);
    system("color 57");
    Sleep(250);
    system("color F4");
    Sleep(250);
    system("color F4");
    Sleep(250);
}

void load()
{
    system("color 8b"); //F1
    cout << "\n\n\n\n\n\n\n\n\n\n\n\n";
    cout << "\t\t\t\t\t正在進入系統..請稍等...";
    for (int i = 0; i <= 100; i += 2)
    {
        cout << "\r\t\t\t\t\t\t\t\t" << i << "%";
        Sleep(50);
        if (i == 48)
        {
            Sleep(1000);
        }
        if (i == 76)
        {
            Sleep(800);
        }
        if (i == 100)
        {
            Sleep(500);
        }
    }

“C語言如何實現航空訂票系統”的內容就介紹到這里了,感謝大家的閱讀。如果想了解更多行業相關的知識可以關注億速云網站,小編將為大家輸出更多高質量的實用文章!

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

汉阴县| 建昌县| 衡水市| 嘉黎县| 克东县| 古蔺县| 桃园县| 靖远县| 友谊县| 互助| 墨竹工卡县| 曲沃县| 海兴县| 澳门| 乐陵市| 句容市| 正宁县| 肇东市| 大关县| 拉孜县| 探索| 恩施市| 甘肃省| 铁岭市| 治县。| 凤翔县| 上虞市| 田阳县| 木里| 台北市| 长子县| 全椒县| 舒城县| 溆浦县| 隆安县| 建水县| 新郑市| 伊春市| 康乐县| 钟山县| 新绛县|