1、#include#include#includeusing namespace std;int ynf(int a,int t) /比较两整数值;int x;if(a=t)x=1;elsex=0;return x; int cmp(string a,string b) /比较两字符串;int x;if(a!=b)x=0;elsex=1;return x; void exchange(string c=b;b=a;a=c;void main() int addflight; /定义增加的航班号;string addorigin; /定义增加的航班对应的起始站;string addfinishpo
2、int;/定义增加的航班对应的终点站;string addsetouttime;/定义增加的航班对应的出发时间;int choice; /定义全局变量;int addnum;/定义增加的航班对应的票数;int price; /定义票价;int in_flight; /定义输入的航班;char zh; zh=n; /初始化 zh;int flightnum=0; /初始化航班总数;string b299; /定义全局变量字符串数组;int a299; /定义全局变量整型数组;while(Y!=zh) /订票系统;char j=Y; coutchoice;switch(choice)case 1:
3、flightnum+; /每执行一次增加航班信息,航班总数数加 1;coutaddflight;coutaddorigin;coutaddfinishpoint;coutaddsetouttime;coutaddnum;coutprice;a(flightnum-1)*3=addflight;b(flightnum-1)*3=addorigin;b(flightnum-1)*3+1=addfinishpoint;b(flightnum-1)*3+2=addsetouttime;a(flightnum-1)*3+1=addnum;a(flightnum-1)*3+2=price;break;ca
4、se 2: /浏览航班信息;coutchoice1;switch(choice1)case 1: /按航班号查询;coutin_flight;coutj;break; case 2: /按终点站查询;string in_finishipoint; /定义字符串变量;coutin_finishipoint;coutj;break; break;case 4: /按航班号排序;while(Y=j)int choice2;coutchoice2;switch(choice2)case 1: / 按航班号从小到大排序;for(int kh=1;kh=ai*3)z=ai*3;ai*3=a(i-1)*3;
5、a(i-1)*3=z;exchange(b(i-1)*3,bi*3);k=ai*3+1;ai*3+1=a(i-1)*3+1;a(i-1)*3+1=k;exchange(b(i-1)*3+1,bi*3+1); g=ai*3+2;ai*3+2=a(i-1)*3+2;a(i-1)*3+2=g;exchange(b(i-1)*3+2,bi*3+2);coutj;break; case 2: / 按航班号从大到小排序;for(int k1=1;k1j;break;break;case 5: /订票;while(Y=j)coutin_flight;coutordernum;if(ordernuma(i-1)*3+1)coutj;break;case 6: while(Y=j)coutin_flight;coutrefundnum;a(i-1)*3+1+=refundnum;coutj;break;case 7: /是否退出系统;coutzh;break;