{
char ch; int i, j, k, m, n; cout<<\请输入查找航班方式: \ cin>>ch; cout< //按编号查询,只显示一个编号的信息,票存在 { cout< //订票失败,数量超过座位余额 { j = 0; for(i = 0; i < 15; i ++) { //cout<<\您还可选择\只将于票数大于等于顾客所需票数的航班列车,其他的具有相同起始站的航班不列出 if(i!=f_no[0] && a[i].s_station == a[f_no[0]].s_station &&a[i].e_station== a[f_no[0]].e_station &&co.a[co.length].c_total<=a[f_no[0]].total_s) { display_flight(a[i]); b[j ++] = i; } } if(j > 0) { if(ch == 'p' && n== 1) //按终点站查询 { int a2; cout< char ch1; int n1; cout<<\您你是否继续订票,继续请安'c',退出请按'q' \ cin>>ch1; if(ch1 == 'c') { cout<<\请输入航班 号: \ cin>>n1; for(i = 0; i < 5; i ++) { if(a[b[i]].f_number==1 && co.a[co.length].c_total <= a[b[i]].total_s ) { co.a[co.length].f_number = b[i]; cout<<\订票成功! 您的订单号为: \ cout< cout< if(Init(k) == 0) { j = 0; for(i = 0; i < 5; i ++) { //cout<<\您还可选择\只将于票数大于 等于顾客所需票数的航 班列车, 其他的具有相同起始站 的航班不列出 if(i!=k && co.a[co.length].c_total <= a[f_no[i]].total_s) { display_flight(a[i]); b[j ++] = i; } } if(j > 0) { char ch1; int n1; cout<<\您你是否继续订票, 继续请安'c',退出请按'q' \ cin>>ch1; if(ch1 == 'c') { cout<<\请输入航班号: \ cout< cin>>n1; for(i = 0; i < 5; i ++) { if(a[b[i]].f_number==n1 && co.a[co.length].c_total<= a[b[i]].total_s ) { co.a[co.length].f_number = b[i]; cout<<\订票成功! 您的订单号为: \ getnumber(b[i], co.length); co.length ++; } } } else { cout<<\欢迎下次使用\ return; } } } } } Takeoff.cpp //退票源代码 #include\ #include\ #include void takeoff()//请用户输入他的证件号,以免出现同名现象 { int i, j, k, m = -1; cout<<\请输入您的证件号: \ cin>>j; cout< while(j != -1) { for(k = 0; k < co.length; k ++) { if(co.a[k].c_number == j) m = k; } if(m > -1) { //cout< 三. 系统实现 1. 完整源代码(见文档末尾) 2. 输出界面: 查询、订票、退票操作截图: 四.设计总结 飞机订票系统主要实现的功能是:查询,订票,退票。其中用到了全局变量,数组等一系列知识,订票是该订票系统最难写的部分,要调用大量的函数。订票系统中数据量很大,写代码精力要高度集中。另外我发现了一个很好的编程习惯,写一个函数,或一个文件时,就编译一次;不能等到代码写完再去编译,当遇到代码量大,函数很多的代码时,小差错不容易被发现,而且报错的位置可能乱指,以后要逐个编译。另外用多文件写代码,思路清晰,函数分明,容易根据函数名找到相应的函数。 flight.h #include using namespace std; #ifndef _flight_h_ #define _flight_h_ typedef struct Flight { int f_number; string start_t; string end_t; float price; //航班信息 //航班号 //起飞时间 //到达时间 //票价