最新国产好看的视频,伊人天堂AV在线,国产Aaaaaa视频,蜜臀视频在线观看一区,人妻av色图,密臀久久久精品影片,青青视频免费观看毛片,久草在线观看视,国产三级精品色情在线

C語言實(shí)現(xiàn)航班訂票系統(tǒng)

 更新時(shí)間:2019年12月27日 09:39:33   作者:zoey-lyly  
這篇文章主要為大家詳細(xì)介紹了C語言實(shí)現(xiàn)航班訂票系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下

本文實(shí)例為大家分享了C語言實(shí)現(xiàn)航班訂票系統(tǒng)的具體代碼,供大家參考,具體內(nèi)容如下

描述:

點(diǎn)定義兩個(gè)鏈表,一個(gè)存儲(chǔ)航班信息,一個(gè)存儲(chǔ)客戶信息;

進(jìn)行一系列簡(jiǎn)單的增刪查找;

代碼如下

#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdlib>
using namespace std;
const int MAXN=250;
typedef struct
{
  string p_id;
  int sum;
  int r;
  int c;
  int selected;
  int select;
  string start;
  string startp;
  string arrive;
  string arrivep;
  int acx[MAXN][MAXN];
} node;
typedef struct Pnode
{
  node data;
  struct Pnode *next;
} Pnode,*Plist;
typedef struct
{
  int r;
  int c;
  string name;
  string kp_id;
  string k_id;
} node1;
typedef struct Knode
{
  node1 data;
  struct Knode *next;
} Knode,*Klist;
void init(Plist &l)
{
  l=new Pnode;
  l->next=NULL;
}
void init(Klist &L)
{
  L=new Knode;
  L->next=NULL;
}
void creatp(Plist &l,int e)
{
  cout<<endl<<endl;
  Plist r=new Pnode;
  r=l;
  for(int i=0; i<e; i++)
  {
    Plist ll=new Pnode;
    cout<<endl;
    cout<<"請(qǐng)依次輸入航班班次,起飛時(shí)間,起飛地點(diǎn),到達(dá)時(shí)間,到達(dá)地點(diǎn),座位行數(shù),列數(shù),總座位數(shù),已被購(gòu)買的數(shù)目,未被購(gòu)買的數(shù)目"<<endl;
    cout<<'\t';
    cin>>ll->data.p_id;
    cout<<" ";
    cin>>ll->data.start;
    cout<<" ";
    cin>>ll->data.startp;
    cout<<" ";
    cin>>ll->data.arrive;
    cout<<" ";
    cin>>ll->data.arrivep;
    cout<<" ";
    cin>>ll->data.r;
    cout<<" ";
    cin>>ll->data.c;
    cout<<" ";
    cin>>ll->data.sum;
    cout<<" ";
    cin>>ll->data.selected;
    cout<<" ";
    cin>>ll->data.select;
    for(int j=1; j<=ll->data.r; j++)
      for(int v=1; v<=l->data.c; v++)
        ll->data.acx[j][v]=0;
    ll->next=NULL;
    r->next=ll;
    r=ll;
  }
}
void creatk(Klist &L,node1 e)
{
  Klist LL=new Knode;
  LL->data=e;
  LL->next=NULL;
  Klist r;
  r=L;
  while(r->next!=NULL)
  {
    r=r->next;
  }
  r->next=LL;
  //cout<<L->next->data.r<<endl;
}
void show(Plist &l)
{
  Plist p=new Pnode;
  p=l->next;
  while(p!=NULL)
  {
    cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<p->data.p_id<<" "<<p->data.start<<" "<<p->data.startp<<" "<<p->data.arrive<<" "<<p->data.arrivep<<" "<<p->data.sum<<" "<<p->data.selected<<" "<<p->data.select<<endl;
    for(int i=1; i<=p->data.r; i++)
    {
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t';
      for(int j=1; j<=p->data.c; j++)
        cout<<p->data.acx[i][j];
      cout<<endl;
    }
    p=p->next;
  }
  return ;
}
void alter(Plist &l,node1 e,int flag)
{
  Pnode *p,*pre;
  p=l->next;
  while(p->data.p_id!=e.kp_id)
  {
    pre=p;
    p=p->next;
  }
  if(flag)
  {
    p->data.select-=1;
    p->data.selected+=1;
    p->data.acx[e.r][e.c]=1;
  }
  else
  {
    p->data.select+=1;
    p->data.selected-=1;
    p->data.acx[e.r][e.c]=0;
  }
  return ;
}
int delet(Klist &L,node1 e)
{
  Klist p,pre;
  p=L;
  while(p->next!=NULL)
  {
    if(p->data.name==e.name&&p->data.k_id==e.k_id&&p->data.kp_id==e.kp_id)
      break;
    pre=p;
    p=p->next;
  }
  if(p==NULL)
    return 0;
  else
  {
    //cout<<"hjdhfjks"<<endl;
    pre->next=p->next;
    free(p);
    return 1;
  }
}
int searchh(Klist &L,node1 e)
{
  Knode *p;
  p=L->next;
  while(p!=NULL)
  {
    if(p->data.name==e.name&&p->data.k_id==e.k_id&&p->data.kp_id==e.kp_id)
    {
      cout<<endl;
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"您的位置是"<<p->data.r<<"行"<<p->data.c<<"列"<<endl;
      return 1;
    }
    p=p->next;
  }
  return 0;
}
void showone(Plist &l,node1 e)
{
  Pnode *p;
  p=l->next;
  while(p!=NULL)
  {
    if(p->data.p_id==e.kp_id)
    {
      cout<<endl;
      cout<<'\t'<<"您的航班信息如下(依次為航班班次,起飛時(shí)間,起飛地點(diǎn),到達(dá)時(shí)間,到達(dá)地點(diǎn),座位總數(shù),已購(gòu)座位數(shù),未購(gòu)座位數(shù))"<<endl;
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<p->data.p_id<<" "<<p->data.start<<" "<<p->data.startp<<" "<<p->data.arrive<<" "<<p->data.arrivep<<" "<<p->data.sum<<" "<<p->data.selected<<" "<<p->data.select<<endl;
      return ;
    }
  }
  return ;
}
int judge(Plist &l,node1 e)
{
  Pnode *p;
  p=l->next;
  while(p!=NULL)
  {
    //cout<<p->data.acx[e.r][e.c]<<endl;
    if(p->data.p_id==e.kp_id)
    {
      if(p->data.acx[e.r][e.c])
        return 0;
    }
    p=p->next;
  }
  return 1;
}
int main()
{
  Plist l;
  Klist L;
  init(l);
  init(L);
  int choose,n;
  node p;
  node1 k;
  cout<<endl<<endl;
  cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"初始化存儲(chǔ)航班信息"<<endl;
  cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"輸入航班總數(shù):";
  cin>>n;
  system("cls");
  creatp(l,n);
  system("cls");
  while(1)
  {
    cout<<endl;
    cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"1.客戶訂票"<<endl;
    cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"2.客戶退票"<<endl;
    cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"3.客戶查詢航班信息"<<endl;
    cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"0.退出系統(tǒng)"<<endl;
    cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"選擇功能:";
    cin>>choose;
    system("cls");
    if(!choose)
    {
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<endl;
      break;
    }
    else if(choose==1)//訂票
    {
      cout<<endl<<endl;
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"航班信息如下"<<endl;
      show(l);
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"輸入客戶姓名,證件號(hào):";
      cin>>k.name>>k.k_id;
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"輸入客戶選擇的航班號(hào),位置(行,列):";
      cin>>k.kp_id>>k.r>>k.c;
      if(judge(l,k))
      {
        creatk(L,k);
        alter(l,k,1);
      }
      else
      {
        cout<<endl;
        cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"座位已有人,不能訂票,請(qǐng)重新選擇!"<<endl;
      }
      getchar();
      getchar();
      system("cls");
    }
    else if(choose==2)//退票
    {
      cout<<endl<<endl;
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"輸入客戶信息(名字,證件號(hào),航班)"<<endl;
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t';
      cin>>k.name>>k.k_id>>k.kp_id;
      int flag=delet(L,k);
      if(flag)
      {
        alter(l,k,0);
        cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"退票成功"<<endl;
      }
      else
      {
        cout<<endl;
        cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"查找失敗,請(qǐng)重新輸入"<<endl;
      }
      getchar();
      getchar();
      system("cls");
    }
    else if(choose==3)
    {
      cout<<endl<<endl;
      cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"輸入客戶信息(名字,證件號(hào),航班):";
      cin>>k.name>>k.k_id>>k.kp_id;
      int flag=searchh(L,k);
      if(flag)
      {
        showone(l,k);
      }
      else
      {
        cout<<'\t'<<'\t'<<'\t'<<'\t'<<'\t'<<"查找失敗,請(qǐng)重新輸入"<<endl;
      }
      getchar();
      getchar();
      system("cls");
    }
  }
}

更多學(xué)習(xí)資料請(qǐng)關(guān)注專題《管理系統(tǒng)開發(fā)》。

以上就是本文的全部?jī)?nèi)容,希望對(duì)大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

  • C++實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)

    C++實(shí)現(xiàn)學(xué)生信息管理系統(tǒng)

    這篇文章主要為大家詳細(xì)介紹了C++實(shí)現(xiàn)學(xué)生信息管理系統(tǒng),文中示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2020-12-12
  • 求解旋轉(zhuǎn)數(shù)組的最小數(shù)字

    求解旋轉(zhuǎn)數(shù)組的最小數(shù)字

    這篇文章主要介紹了求解旋轉(zhuǎn)數(shù)組的最小數(shù)字的相關(guān)資料,需要的朋友可以參考下
    2017-05-05
  • 詳解C++中typedef 和 #define 的區(qū)別

    詳解C++中typedef 和 #define 的區(qū)別

    這篇文章主要介紹了C++中typedef 與 #define 的區(qū)別,本文通過實(shí)例代碼給大家介紹的非常詳細(xì),對(duì)大家的學(xué)習(xí)或工作具有一定的參考借鑒價(jià)值,需要的朋友可以參考下
    2021-09-09
  • C++實(shí)現(xiàn)LeetCode(111.二叉樹的最小深度)

    C++實(shí)現(xiàn)LeetCode(111.二叉樹的最小深度)

    這篇文章主要介紹了C++實(shí)現(xiàn)LeetCode(111.二叉樹的最小深度),本篇文章通過簡(jiǎn)要的案例,講解了該項(xiàng)技術(shù)的了解與使用,以下就是詳細(xì)內(nèi)容,需要的朋友可以參考下
    2021-07-07
  • C++17中std::byte的具體使用詳解

    C++17中std::byte的具體使用詳解

    這篇文章主要為大家詳細(xì)介紹了C++17中std::byte的具體使用,文中通過示例代碼介紹的非常詳細(xì),具有一定的參考價(jià)值,感興趣的小伙伴們可以參考一下
    2023-11-11
  • 深入遍歷二叉樹的各種操作詳解(非遞歸遍歷)

    深入遍歷二叉樹的各種操作詳解(非遞歸遍歷)

    本篇文章是對(duì)遍歷二叉樹的各種操作進(jìn)行了詳細(xì)的分析介紹,需要的朋友參考下
    2013-05-05
  • c語言10個(gè)經(jīng)典小程序

    c語言10個(gè)經(jīng)典小程序

    c語言的經(jīng)典程序,學(xué)習(xí)c語言的初學(xué)者可以參考下
    2013-01-01
  • 最新評(píng)論

    临潭县| 江孜县| 枣庄市| 广平县| 南昌市| 隆回县| 徐汇区| 泸定县| 通州区| 新营市| 天峻县| 松原市| 东乌珠穆沁旗| 金山区| 林西县| 新乡市| 茌平县| 方正县| 新密市| 揭西县| 夏津县| 苍南县| 阜平县| 彰武县| 建始县| 杭锦后旗| 安丘市| 汽车| 霍林郭勒市| 莎车县| 永昌县| 吉木萨尔县| 日照市| 恩平市| 莱西市| 安塞县| 景洪市| 三门峡市| 龙里县| 五常市| 盐源县|