欧美色欧美亚洲高清在线观看,国产特黄特色a级在线视频,国产一区视频一区欧美,亚洲成a 人在线观看中文

  1. <ul id="fwlom"></ul>

    <object id="fwlom"></object>

    <span id="fwlom"></span><dfn id="fwlom"></dfn>

      <object id="fwlom"></object>

      鐵路客運售票模擬系統(tǒng)(共5篇)

      時間:2019-05-13 12:55:56下載本文作者:會員上傳
      簡介:寫寫幫文庫小編為你整理了多篇相關(guān)的《鐵路客運售票模擬系統(tǒng)》,但愿對你工作學(xué)習(xí)有幫助,當(dāng)然你在寫寫幫文庫還可以找到更多《鐵路客運售票模擬系統(tǒng)》。

      第一篇:鐵路客運售票模擬系統(tǒng)

      學(xué)生實習(xí)報告

      課程名稱_ 數(shù)據(jù)結(jié)構(gòu)與數(shù)據(jù)處理應(yīng)用訓(xùn)練 題目名稱 學(xué)生學(xué)院 專業(yè)班級

      學(xué) 號

      學(xué)生姓名

      指導(dǎo)教師

      2014 年 2 月

      [單擊此處添加課程設(shè)計題目]

      XXX

      計算分院 計算1103

      【摘要】

      模擬鐵路客運售票系統(tǒng),采用鏈表結(jié)構(gòu)儲存數(shù)據(jù),有訂票、退票、查詢、修改、讀取文件等功能模塊,整體系統(tǒng)運行為一個無限循環(huán),根據(jù)輸入指令進行不同操作,主要知識有結(jié)構(gòu)的定義,鏈表的操作,循環(huán)的應(yīng)用。

      【關(guān)鍵詞】

      鐵路客運售票模擬系統(tǒng),查詢車次,車票預(yù)訂,辦理退票 內(nèi)容與要求

      鐵路客運售票模擬系統(tǒng) 【問題描述】

      鐵路客運售票系統(tǒng)的業(yè)務(wù)活動包括:查詢車次、車票預(yù)訂和辦理退票。試設(shè)計一個鐵路客運售票模擬系統(tǒng),使上述業(yè)務(wù)可以借助計算機來完成。【具體要求】

      鐵路客運售票處的計算機系統(tǒng)可以為客戶提供下列各項服務(wù):

      1. 查詢車次:根據(jù)旅客提供的出發(fā)站、到達站、出發(fā)日輸出下列信息:

      車次號、出發(fā)站、到達站、出發(fā)時間、到達時間、各類車票的余票額(包括軟臥、硬臥、軟座、硬座、無座)等。還可根據(jù)客戶要求,輸出某車次從起點站到終點站的各站點的名稱及出發(fā)時間和到達時間。

      2.承辦訂票業(yè)務(wù):根據(jù)客戶提出的要求(日期、車次號、座位類別、訂票數(shù)額)查詢該車次該座位類別票額情況,若尚有余額,則為客戶辦理訂票手續(xù),并輸出座位號(座位號信息的輸出可作為選做部分);若無票或余票額少于訂票額,則需要重新詢問客戶要求。若客戶需要,可預(yù)約登記排隊等候。

      3.承辦退票業(yè)務(wù):根據(jù)客戶提供的情況(日期、車次號、座位類別、退票數(shù)額),為客戶辦理退票手續(xù),然后查詢該車次該座位類別是否有人預(yù)約登記,首先詢問排在第一的客戶,若退票數(shù)能滿足他的要求,則為他辦理訂票手續(xù),否則依次詢問其他排隊預(yù)約的客戶。為簡化問題,可以規(guī)定同一個座位只能售出一次票,即不考慮同一個座位分不同路段出售多次。還可規(guī)定只能查詢或預(yù)訂未來3天之內(nèi)的車票,即每個車次只需分別保存3個班次的售票情況。【實現(xiàn)提示】

      每個車次應(yīng)包含的信息有:車次號、出發(fā)日、起點站名、各中途站名、終點站名、各站點的到達時間與出發(fā)時間、各類座位車票定額、各類座位余票額、各座位是否已售出信息(選做內(nèi)容,可用一張表記錄每個座位是否已售出)、各類座位已訂票的客戶名單(包括姓名、出發(fā)站、到達站、訂票額、座位號(選做))和各類座位預(yù)約登記的客戶名單(包括姓名、出發(fā)站、到達站、所需票額)。這最后兩項顯然可以分別用線性表和隊列實現(xiàn)(每一類別的座位需有各自的線性表和隊列)。為查找方便,已訂票客戶的線性表應(yīng)按客戶姓名有序,并且,為插入和刪除方便,應(yīng)以鏈表作存儲結(jié)構(gòu);由于預(yù)約人數(shù)無法預(yù)料,隊列也應(yīng)以鏈表作存儲結(jié)構(gòu)。整個系統(tǒng)需匯總各車次的情況記錄在一張線性表上,由于車次基本不變,可采用順序存儲結(jié)構(gòu),并按車次有序,因為每個車次需保存未來3天的售票情況,可考慮每個車次的每一班次是這張表上的一個記錄,也可以每個車次是一個記錄,里面分別包含3趟班次的售票情況。每個記錄需定義成一個結(jié)構(gòu)類型。【測試數(shù)據(jù)】

      自己設(shè)計,報告上要求寫出多批數(shù)據(jù)測試結(jié)果?!緦崿F(xiàn)說明】

      每個同學(xué)可以根據(jù)自己的實際情況對該鐵路客運售票模擬系統(tǒng)的功能進行增減。有能力的同學(xué)在完成上述功能的基礎(chǔ)上,可以充分發(fā)揮自己的想象力,增加該系統(tǒng)的功能和其它服務(wù)項目,如可以按照實用性來完善上述模擬系統(tǒng),考慮輸出座位號信息、同一個座位允許分不同路段出售多次等;能力較弱的同學(xué)則可以簡化上述系統(tǒng),如不考慮預(yù)約登記排隊等候車票、不考慮各種座位類別(即每個車次只有一種座位)、還可以不考慮中途站點(即每個車次只設(shè)置起點站與終點站,中間不停)等。總體設(shè)計

      開始判斷操作指令繼續(xù)下一輪指令1.訂票先根據(jù)出發(fā)站和到達站查詢列車班次,然后訂票2.退票根據(jù)姓名,時間,車次,座位類別進行退票3.查詢輸出所有路線信息與乘客信息5.讀取文件讀取存檔文件中的路線信息和乘客信息1.增加路線輸入增加路線信息4.修改路線判斷操作指令2.刪除路線輸入刪除路線日期與車次6.退出退出程序3.修改密碼3 詳細設(shè)計

      路線信息

      typedef struct trainline //路線 { char date[9];//日期

      char train_num[8];//車次號 struct station *sta;//途經(jīng)站

      char begin_time[6];//出發(fā)時間

      char end_time[6];//到達時間

      int RW;//軟臥余量

      int YW;//硬臥余量

      int RZ;//軟座余量

      int YZ;//硬座余量

      int WZ;//無座余量 struct trainline *next;//下一個節(jié)點 }trainline;

      ??空军c信息

      typedef struct station//停靠站 { char stop[9];//??空久?/p>

      char stop_time;//停靠時間

      struct station *next;//下一個節(jié)點 }station;

      乘客訂票信息

      typedef struct customer //乘客 { char name[9];//顧客名

      char date[9];//日期

      char train_num[9];//車次號 int seat_level;//座位類別

      int seat_num;//座位數(shù)量

      struct customer *next;//下一個節(jié)點 }customer;

      找到路線鏈表中的末尾節(jié)點

      status increase_train(trainline *l,char *date,char *train_num,station *stat,char *begin_time,char *end_time,int RW,int YW,int RZ,int YZ,int WZ)//增加路線 將需要插入的路線信息插入到鏈表中指定節(jié)點之后

      status insert_trainline(trainline **p,char *date,char *train_num,station *stat,char *begin_time,char *end_time,int RW,int YW,int RZ,int YZ,int WZ)//trainline鏈表插入操作

      將需要插入的乘客訂票信息插入到鏈表中

      status insert_customer(customer **p,char *name,char *date,char *train_num,int seat,int seat_num)//customer鏈表插入操作

      刪除某條路線,首先搜索到該路線,然后在鏈表中跳過該節(jié)點

      status delete_trainline(trainline *h,char *date,char *train_num)//刪除路線

      刪除某條乘客訂票記錄,首先搜索到該記錄,然后在鏈表中跳過該節(jié)點

      status delete_customer(customer *h,char *date,char *train_num)//刪除顧客 修改路線座位余量,首先搜索到該路線,然后刪除對應(yīng)的座位類別的余量

      trainline *modefy_trainline(trainline *l,char *date,char *train_num,int seat_level,int num)//修改trainline鏈表中的數(shù)據(jù) 退票,首先搜索到該訂票記錄,然后確定退票數(shù)量,如果大于訂票數(shù)量,則減去退票數(shù)量;如果等于退票數(shù)量,則刪除此訂票記錄;如果小于,則輸出數(shù)量不足,退票失敗。如果退票成功,則路線中相應(yīng)座位余量增加。

      status delete_cus(customer *h,trainline *l,char *name,char *date,char *train_num,int level,int num)//乘客退票

      以下兩個函數(shù)是為了方便操作所賦予的初始化數(shù)據(jù)

      status creat_trainline(trainline **l)//創(chuàng)建trainline單鏈表 status creat_customer(customer **l)////創(chuàng)建customer單鏈表

      訂票查詢,根據(jù)提供站點,查找路線,判斷同意路線中是否有這兩個站點,并且順序正確 void book_search(trainline *l,char *begin_place,char *end_place)//訂票查詢函數(shù) 訂票,首先找到該車次,然后判斷余量是否夠,如果夠,則訂票;反之,訂票失敗。訂票成功,則增加乘客訂票記錄,兵減少相應(yīng)車次的座位余量。

      status book(trainline *l,char *date,char *train_num,customer *c,char *name,int seat_level,int num)//訂票函數(shù)

      根據(jù)路線鏈表和乘客鏈表逐個輸出信息

      status print_trainline(trainline *l)//打印路線信息 status print_customer(customer *l)//打印乘客信息

      根據(jù)路線鏈表和乘客鏈表,逐個在 C盤 trainline.dat 和 customer.dat 文件中輸出信息 status save_trainline(trainline *l)//保存trainline.dat status save_customer(customer *l)//保存乘客信息 customer.dat

      從 C盤 trainline.dat 和 customer.dat 文件中讀取記錄,并用訂票和增加路線函數(shù)逐條添加到系統(tǒng)中

      status load_trainline(trainline *l)//導(dǎo)入路線信息,必須為5個站 status load_customer(customer *l)//導(dǎo)入乘客信息 程序測試 查詢路線、乘客信息

      status print_trainline(trainline *l)//打印路線信息 status print_customer(customer *l)//打印顧客信息 訂票 首先查詢 出發(fā)站-終點站

      void book_search(trainline *l,char *begin_place,char *end_place)//訂票查詢函數(shù)

      然后根據(jù)查詢結(jié)果購買自己需要車次 status book(trainline *l,char *date,char *train_num,customer *c,char *name,int seat_level,int num)//訂票函數(shù)

      訂票后的查詢結(jié)果 退票(可以全部退完,也可以退一部分)status delete_cus(customer *h,trainline *l,char *name,char *date,char *train_num,int level,int num)//乘客退票

      退票后查詢結(jié)果 修改路線 默認密碼12345678 代碼:pass[9]=“12345678” 增加路線 status increase_train(trainline *l,char *date,char *train_num, station *stat,char *begin_time,char *end_time, int RW,int YW,int RZ,int YZ,int WZ)//增加路線

      注意時間“:”為英文字符,輸入中文字符會報錯

      增加路線后查詢結(jié)果 刪除路線

      刪除路線后查詢結(jié)果 讀入文件

      status load_trainline(trainline *l)//導(dǎo)入路線信息,必須為5個站 status load_customer(customer *l)//導(dǎo)入乘客信息

      隱藏密碼函數(shù)

      status inputpassword(char cc[9])//隱藏密碼為*號的函數(shù)

      系統(tǒng)存檔 status save_trainline(trainline *l)//保存trainline.dat status save_customer(customer *l)//保存顧客信息 customer.dat

      每完成一輪操作 系統(tǒng)自動存檔一次,如果需要繼續(xù)上一回的存檔,請打開后直接選5讀入存檔總結(jié)

      [單擊此處添加正文]

      參考文獻

      1.徐孝凱.數(shù)據(jù)結(jié)構(gòu)實用教程.清華大學(xué)出版社.2006.9

      附錄

      Slove.h #define OK 1 #define TRUE 1 #define FALSE 0 #define ERROR 0 #define OVERFLOW-2 #define PR printf #define RUANW 1 #define YINGW 2 #define RUANZ 3 #define YINGZ 4 #define WUZ 5

      typedef int status;typedef struct trainline //路線 { char date[9];//日期

      char train_num[8];//車次號 //char begin_place[9];//出發(fā)地

      //char end_place[9];//目的地

      struct station *sta;//途經(jīng)站

      char begin_time[6];//出發(fā)時間

      char end_time[6];//到達時間 // int total;//座位總數(shù) // int left;int RW;//軟臥余量 int YW;//硬臥余量

      int RZ;//軟座余量

      int YZ;//硬座余量

      int WZ;//無座余量

      struct trainline *next;//下一個節(jié)點 }trainline;

      typedef struct station//??空?{ char stop[9];//??空久?/p>

      char stop_time;//??繒r間

      struct station *next;//下一個節(jié)點 }station;

      typedef struct customer //乘客 { char name[9];//顧客名

      char date[9];//日期

      char train_num[9];//車次號

      int seat_level;//座位類別

      int seat_num;//座位數(shù)量

      struct customer *next;//下一個節(jié)點 }customer;

      station *init_station()//初始化途經(jīng)站 { station *l;l=(station*)malloc(sizeof(station));

      if(l==NULL)exit(0);

      l->next=NULL;return l;}

      trainline *init_trainline()//初始化路線鏈表 { trainline *l;

      l=(trainline*)malloc(sizeof(trainline));

      if(l==NULL)exit(0);

      l->next=NULL;return l;}

      customer * init_customer()//初始化乘客鏈表 { customer *l;l=(customer*)malloc(sizeof(customer));

      if(l==NULL)exit(0);

      l->next=NULL;return l;}

      status insert_trainline(trainline **p,char *date,char *train_num,//char *begin_place,char *end_place,station *stat,char *begin_time,char *end_time,int RW,int YW,int RZ,int YZ,int WZ)//trainline鏈表插入操作 { trainline *q;q=(trainline*)malloc(sizeof(trainline));

      strcpy(q->date , date);strcpy(q->train_num , train_num);//strcpy(q->begin_place , begin_place);//strcpy(q->end_place , end_place);q->sta=stat;strcpy(q->begin_time , begin_time);strcpy(q->end_time , end_time);q->RW =RW;q->YW =YW;q->RZ =RZ;q->YZ =YZ;q->WZ =WZ;q->next=NULL;(*p)->next=q;(*p)=(*p)->next;//PR(“insert %d ,%dis succssed!n”,e,bl);return OK;}

      status insert_customer(customer **p,char *name,char *date,char *train_num,int seat,int seat_num)//customer鏈表插入操作 { customer *q;q=(customer*)malloc(sizeof(customer));

      /* { PR(“內(nèi)存分配失敗n”);return OVERFLOW;}*/ strcpy(q->name , name);strcpy(q->date , date);strcpy(q->train_num , train_num);q->seat_level =seat;q->seat_num =seat_num;q->next=NULL;(*p)->next=q;(*p)=(*p)->next;//PR(“insert %d ,%dis succssed!n”,e,bl);return OK;}

      status delete_trainline(trainline *h,char *date,char *train_num)//刪除路線 { trainline *p,*pr;pr=h;p=pr->next;while(p!=NULL){

      if(strcmp(date,p->date)==0 && strcmp(train_num,p->train_num)==0)

      {

      pr->next =p->next;

      PR(“刪除 %s 車次n”,p->date);

      return OK;

      }

      pr=pr->next;

      p=pr->next;} PR(“無此車次,無法刪除!n”);return ERROR;}

      status delete_customer(customer *h,char *date,char *train_num)//刪除顧客 { customer *p,*pr;pr=h;p=pr->next;while(p!=NULL){

      if(strcmp(date,p->date)==0 && strcmp(train_num,p->train_num)==0)

      {

      pr->next =p->next;

      }

      pr=pr->next;

      p=pr->next;} return OK;}

      trainline *modefy_trainline(trainline *l,char *date,char *train_num,int seat_level,int num)//修改trainline鏈表中的數(shù)據(jù) { trainline *p;p=l->next;for(;p!=NULL;p=p->next){

      if(strcmp(date,p->date)==0 && strcmp(train_num,p->train_num)==0)

      {

      if(seat_level == RUANW)p->RW += num;

      else if(seat_level == YINGW)p->YW += num;

      else if(seat_level == RUANZ)p->RZ += num;

      else if(seat_level == YINGZ)p->YZ += num;

      else if(seat_level == WUZ)p->WZ += num;

      // PR(“modefy %sn”,p->line_num);

      return l;

      } } PR(“沒有這個路線,無法完成修改任務(wù)!n”);return 0;}

      status delete_cus(customer *h,trainline *l,char *name,char *date,char *train_num,int level,int num)//乘客退票 { customer *p,*pr;int seat_num;// qr=h;pr=h;p=pr->next;// PR(“開始刪除n”);while(p!=NULL){

      if(strcmp(name,p->name)==0 && strcmp(date,p->date strcmp(train_num,p->train_num)==0 && level==p->seat_level)

      {

      seat_num=p->seat_num;

      l=modefy_trainline(l,date,train_num,level,num);

      if(num == seat_num){

      pr->next =p->next;

      PR(“乘客 %s 退票成功!n”,p->name);

      }

      else if(num < seat_num){

      p->seat_num-= num;

      PR(“乘客 %s 退票成功!n”,p->name);

      }

      else

      PR(“數(shù)量不足,退票失敗!n”,p->name);

      return OK;

      }

      pr=pr->next;

      p=pr->next;} PR(“無此顧客,無法退票!n”);return ERROR;}

      status creat_trainline(trainline **l)//創(chuàng)建trainline單鏈表 { trainline *p=*l;int i=0;char *date[3]={“20140224”,“20140226”,“20140225”};char *train_num[3]={“T01”,“D02”,“G03”};char place[3][5][9]={“北京”,“杭州”,“上?!?“南昌”,“廣州”,“廣州”,“上?!?“金山”,“北京”,“敦煌”,“嘉興”,“北京”,“上?!?“山西”,“深圳”};station *stat[3];for(i=0;i<3;i++){

      stat[i]=init_station();

      for(int j=0;j<5;j++){

      station *st;

      st=(station*)malloc(sizeof(station));

      strcpy(st->stop,place[i][j]);

      //可以在這里加??繒r間

      st->next=stat[i];

      stat[i]=st;)==0 &&

      }

      //stat[i]->next=NULL;} char *begin_time[3]={“12:02”,“22:42”,“05:09”};char *end_time[3]={“17:15”,“06:07”,“10:54”};int RW[3]={100,100,100};int YW[3]={100,100,100};int RZ[3]={100,100,100};int YZ[3]={100,100,100};int WZ[3]={100,100,100};for(i=0;i<3;i++)

      insert_trainline(&p,date[i],train_num[i],stat[i],//begin_place[i],end_place[i],begin_time[i],end_time[i],RW[i],YW[i],RZ[i],YZ[i],WZ[i]);

      return OK;}

      status creat_customer(customer **l)////創(chuàng)建customer單鏈表 { customer *p=*l;int i=0;char *name[3]={“yangj”,“yunhl”,“fangs”};char *date[3]={“20140224”,“20140225”,“20140226”};char *train_num[3]={“T01”,“G03”,“D02”};int seat_level[3]={RUANW,YINGZ,WUZ};int seat_num[3]={2,3,4};for(i=0;i<3;i++)

      insert_customer(&p,name[i],date[i],train_num[i],seat_level[i],seat_num[i]);

      return OK;}

      status increase_train(trainline *l,char *date,char *train_num,station *stat,char *begin_time,char *end_time,int RW,int YW,int RZ,int YZ,int WZ)//增加路線 { trainline *p=l->next;for(;p->next!=NULL;p=p->next){} insert_trainline(&p,date,train_num,stat,//begin_place,end_place,begin_time,end_time,RW,YW,RZ,YZ,WZ);PR(“增加車次 %s %s 成功!n”,date,train_num);return OK;}

      status book(trainline *l,char *date,char *train_num,customer *c,char *name,int seat_level,int num)//訂票函數(shù) { trainline *p=l;customer *q=c->next;p=l->next;for(;q->next!=NULL;q=q->next){} // PR(“%sn”,q->name);for(;p!=NULL;p=p->next){

      if(strcmp(date,p->date)==0)

      {

      if(seat_level == RUANW && p->RW >0)

      {

      PR(“恭喜您!訂票成功!n”);

      insert_customer(&q,name,date,train_num,seat_level,num);

      p->RW-=num;

      return OK;

      }

      else if(seat_level == YINGW && p->YW >0)

      {

      PR(“恭喜您!訂票成功!n”);

      insert_customer(&q,name,date,train_num,seat_level,num);

      p->YW-=num;

      return OK;

      }

      else if(seat_level == RUANZ && p->RZ >0)

      {

      PR(“恭喜您!訂票成功!n”);

      insert_customer(&q,name,date,train_num,seat_level,num);

      p->RZ-=num;

      return OK;

      }

      else if(seat_level == YINGZ && p->YZ >0)

      {

      PR(“恭喜您!訂票成功!n”);

      insert_customer(&q,name,date,train_num,seat_level,num);

      p->YZ-=num;

      return OK;

      }

      else if(seat_level == WUZ && p->WZ >0)

      {

      PR(“恭喜您!訂票成功!n”);

      insert_customer(&q,name,date,train_num,seat_level,num);

      p->WZ-=num;

      return OK;

      }

      else PR(“對不起,余量不足!n”);

      return 0;

      } } PR(“對不起,沒有這個路線號!n”);return ERROR;}

      void book_search(trainline *l,char *begin_place,char *end_place)//訂票查詢函數(shù) { trainline *p=l;//customer *q=c->next;p=l->next;//for(;q->next!=NULL;q=q->next){} // PR(“%sn”,q->name);for(;p!=NULL;p=p->next){

      station *st=p->sta;

      int stop_begin=0,stop_end=0,flag=1;

      for(;st->next!=NULL;st=st->next){

      if(strcmp(begin_place,st->stop)==0)

      stop_begin=flag++;

      if(strcmp(end_place,st->stop)==0)

      stop_end=flag++;

      if(stop_begin==1 && stop_end==2){

      PR(“%15s%5s%12s%c%5s%10d%5d%5d%5d%5dn”,p->date ,p->train_num ,//p->begin_place ,'-',p->end_place ,p->begin_time ,'-',p->end_time ,p->RW ,p->YW,p->RZ ,p->YZ ,p->WZ);

      station *st=p->sta;

      PR(“途經(jīng): ”);

      for(;st->next!=NULL;st=st->next){

      PR(“%s ”,st->stop);

      }

      PR(“n”);

      break;

      }

      } } }

      status print_trainline(trainline *l)//打印路線信息 { trainline *p=l->next;for(;p!=NULL;p=p->next){

      PR(“%15s%5s%12s%c%5s%10d%5d%5d%5d%5dn”,p->date ,p->train_num ,//p->begin_place ,'-',p->end_place ,p->begin_time ,'-',p->end_time ,p->RW ,p->YW,p->RZ ,p->YZ ,p->WZ);

      station *st=p->sta;

      PR(“途經(jīng): ”);

      for(;st->next!=NULL;st=st->next){

      PR(“%s ”,st->stop);

      }

      PR(“n”);}

      return OK;}

      status print_customer(customer *l)//打印顧客信息 { customer *p=l->next;for(;p!=NULL;p=p->next)

      PR(“%5s %9s %5s %6d %6dn”,p->name ,p->date ,p->train_num ,p->seat_level ,p->seat_num);

      return OK;}

      status save_trainline(trainline *l)//保存trainline.dat { FILE *fp_trainline;trainline *p=l->next;char filename[]=“c: rainline.dat”;if((fp_trainline=fopen(filename,“wb”))==NULL){

      printf(“can not open file to write:%sn”,filename);

      return ERROR;} for(;p!=NULL;p=p->next){

      fprintf(fp_trainline,“%s,%s,%s,%s,%d,%d,%d,%d,%d,”,p->date ,p->train_num ,//p->begin_place ,p->end_place ,p->begin_time ,p->end_time ,p->RW ,p->YW ,p->RZ ,p->YZ ,p->WZ);

      station *st=p->sta;

      for(;st->next!=NULL;st=st->next){

      fprintf(fp_trainline,“%s,”,st->stop);

      }

      fprintf(fp_trainline,“#”);} fclose(fp_trainline);return OK;}

      status save_customer(customer *l)//保存顧客信息 customer.dat { FILE *fp_customer;customer *p=l->next;char filename[]=“c:customer.dat”;if((fp_customer=fopen(filename,“wb”))==NULL){

      printf(“can not open file to write:%sn”,filename);

      return ERROR;} for(;p!=NULL;p=p->next){

      // PR(“%s,%s,%dn”,p->name ,p->line_num ,p->seat_num);

      fprintf(fp_customer,“%s,%s,%s,%d,%d,#”,p->name ,p->date ,p->train_num ,p->seat_level ,p->seat_num);} fclose(fp_customer);return OK;}

      int changStrInt(char *ch)//把字符串轉(zhuǎn)化為整型 { int a=1,b=0,c=0,i;for(i=strlen(ch)-1;i>=0;i--){

      if(ch[i]<58&&ch[i]>47)

      {

      b=a*(ch[i]-48);

      a=a*10;

      c=c+b;

      }

      else

      {

      PR(“%c 不合法,無法將此字符串轉(zhuǎn)化為整形!n”,ch[i]);

      return 0;

      }

      // printf(“the c is %dn”,c);} return c;}

      status load_trainline(trainline *l)//導(dǎo)入路線信息,必須為5個站 { FILE *fp_trainline;int flag=0,i=0;char ch;char date[9];//日期

      char train_num[9];//車次號

      char begin_time[6],end_time[6];//時間

      char RW_str[5],YW_str[5],RZ_str[5],YZ_str[5],WZ_str[5];//座位余量字符串

      int RW,YW,RZ,YZ,WZ;//座位余量 char place[9];//站名

      station *sta=init_station();//途經(jīng)站

      // trainline *p=l;char filename[]=“c: rainline.dat”;if((fp_trainline=fopen(filename,“rb”))==NULL){

      printf(“can not open file to load:%sn”,filename);

      return ERROR;} while(!feof(fp_trainline)){

      ch=fgetc(fp_trainline);

      if(ch!='#')

      {

      if(flag==0&&ch!=','){ date[i]=ch;i++;} else if(flag==1&&ch!=','){ train_num[i]=ch;i++;} else if(flag==2&&ch!=','){ begin_time[i]=ch;i++;} else if(flag==3&&ch!=','){ end_time[i]=ch;i++;} else if(flag==4&&ch!=','){ RW_str[i]=ch;i++;} else if(flag==5&&ch!=','){ YW_str[i]=ch;i++;} else if(flag==6&&ch!=','){ RZ_str[i]=ch;i++;} else if(flag==7&&ch!=','){ YZ_str[i]=ch;i++;} else if(flag==8&&ch!=','){ WZ_str[i]=ch;i++;

      } else if(flag>=9&&flag<=13&&ch!=','){

      place[i]=ch;

      i++;} else if(ch==','){

      if(flag==0)date[i]=0;

      else if(flag==1)train_num[i]=0;

      else if(flag==2)begin_time[i]=0;

      else if(flag==3)end_time[i]=0;

      else if(flag==4)RW_str[i]=0;

      else if(flag==5)YW_str[i]=0;

      else if(flag==6)RZ_str[i]=0;

      else if(flag==7)YZ_str[i]=0;

      else if(flag==8)WZ_str[i]=0;

      else if(flag>=9&&flag<=13){

      place[i]=0;

      station *st;

      st=(station*)malloc(sizeof(station));

      strcpy(st->stop,place);

      //可以在這里加??繒r間

      st->next=sta;

      sta=st;

      }

      flag++;

      i=0;} else {

      PR(“錯誤n”);

      return ERROR;} } else { flag=0;i=0;RW=changStrInt(RW_str);YW=changStrInt(YW_str);RZ=changStrInt(RZ_str);YZ=changStrInt(YZ_str);WZ=changStrInt(WZ_str);

      PR(“%15s%5s%6s%c%5s%5d%5d%5d%5d%5dn”,date ,train_num ,begin_time ,'-',end_time ,RW ,YW,RZ ,YZ ,WZ);

      PR(“途經(jīng): ”);

      station *st=sta;

      for(;st->next!=NULL;st=st->next){

      PR(“%s ”,st->stop);

      }

      PR(“n”);

      //increase_train(l,date,train_num,sta,//

      begin_time,end_time,RW,YW,RZ,YZ,WZ);

      insert_trainline(&l,date,train_num,sta,begin_time,end_time,RW,YW,RZ,YZ,WZ);

      station *ss=init_station();

      sta=ss;

      } } fclose(fp_trainline);return OK;}

      status load_customer(customer *l)//導(dǎo)入乘客信息 { FILE *fp_customer;int flag=0,i=0;char ch;char name[9];char date[9];//日期

      char train_num[9];//車次號

      char seat_level_str[5],num_str[5];int seat_level,num;//座位類別,數(shù)量 // customer *p=*l;char filename[50]=“c:customer.dat”;if((fp_customer=fopen(filename,“rb”))==NULL){

      printf(“can not open file to load:%sn”,filename);

      return ERROR;}

      while(!feof(fp_customer)){ ch=fgetc(fp_customer);//printf(“%cn”,ch);if(ch!='#'){

      if(flag==0&&ch!=',')

      {

      name[i]=ch;

      i++;

      }

      else if(flag==1&&ch!=',')

      {

      date[i]=ch;

      i++;

      }

      else if(flag==2&&ch!=',')

      {

      train_num[i]=ch;

      i++;

      }

      else if(flag==3&&ch!=',')

      {

      seat_level_str[i]=ch;

      i++;

      }

      else if(flag==4&&ch!=',')

      {

      num_str[i]=ch;

      i++;

      }

      else if(ch==',')

      {

      if(flag==0)name[i]=0;

      else if(flag==1)date[i]=0;

      else if(flag==2)train_num[i]=0;

      else if(flag==3)seat_level_str[i]=0;

      else if(flag==4)num_str[i]=0;

      flag++;

      i=0;

      }

      else

      {

      PR(“錯誤n”);

      return ERROR;

      }

      }

      else

      {

      flag=0;

      seat_level=changStrInt(seat_level_str);

      num=changStrInt(num_str);

      PR(“%10s %10s %5d %5dn”,name ,date ,train_num ,seat_level ,num);

      insert_customer(&l,name,date,train_num,seat_level,num);

      // p=p->next;

      } } fclose(fp_customer);return OK;}

      status inputpassword(char cc[9])//隱藏密碼為*號的函數(shù) { char c;int i;for(i=0;c=getch();i++){

      if(c==13)break;/*13='n'*/

      else

      {

      cc[i]=c;

      printf(“*”);

      } } cc[i]='