首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 开发语言 > C++ >

关于基于Win32开发的模拟航空订票系统的有关问题

2012-04-14 
关于基于Win32开发的模拟航空订票系统的问题系统要求:程序显示下列菜单选项:Pleasetype1for“smoking”Pleas

关于基于Win32开发的模拟航空订票系统的问题
系统要求:
程序显示下列菜单选项:
Please   type   1   for   “smoking”
Please   type   2   for   “nonsmoking”
如果输入1,则程序指定吸烟舱位(座位1到5),如果输入2,则程序指定非吸烟舱位(座位6到10)。程序应输出一个登机牌,表示座位号和是否为吸烟舱位。程序不能再订已经订过的座位。吸烟舱位已满时,应该询问可否订非吸烟舱位;同样,非吸烟舱位已满时,应询问可否订吸烟舱位。如果同意,再相应订座,否则打印消息:“Next   flight   leaves   in   3   hours”。

我的代码:
#include   <string>
#include   <iostream>
using   namespace   std;

int   a[9]   =   {0};
int   smoking_booked   =   0;
int   nonsmoking_booked   =   0;
void   smoking_book();
void   nonsmoking_book();

void   main(){

void   system();
system();
}

void   system(){

int   choice;
cout   < <   "Welcome   for   using   Universal   Airline   Ticket   Booking   System!\n "
  < <   "Please   type   0   to   exit   the   system.\n "
  < <   "Please   type   1   for   \ "smoking\ ".\n "
  < <   "Please   type   2   for   \ "nonsmoking\ ". "   < <   endl;
cin   > >   choice;
if   (choice   ==   0)   cout   < <   "Thank   you   for   using,   goodbye! "   < <   endl;
else   if   (choice   ==   1)   smoking_book();
else   if   (choice   ==   2)   nonsmoking_book();
else{

cout   < <   "Please   input   0,   1   or   2!\n "   < <   endl;
system();
}
}

void   smoking_book(){

int   identify   =0;
for   (int   i=0;   i <5;){
if   (a[i]   ==   1)   i++;
else   {
a[i]   =   1;
cout   < <   "Congratulations!   You 've   book   smoking   seat   successfully!\n "
  < <   "The   seat   NO.   is   "   < <   i   +   1   < <   ",   Please   enjoy   your   trip!\n "
  < <   endl;
identify   =   1;
break;
}
}
if   (identify   ==   0){

smoking_booked   =   1;
if   (nonsmoking_booked){

cout   < <   "We   are   so   sorry   that   all   of   our   tickets   had   sold   out.\n "
  < <   "Please   come   and   take   our   next   flight,   next   flight   leaves   in   3   hours.\n "
  < <   "Thank   you   for   using,   See   you   next   time!\n "   < <   endl;
system();
}
string   decision;
cout   < <   "We   are   sorry   to   tell   you   that   smoking   seat   had   sold   out.\n "
  < <   "Would   you   please   change   to   nonsmoking   seat?(Y/N) "   < <   endl;
cin   > >   decision;
if   (decision   ==   "Y ")   nonsmoking_book();


else   if   (decision   ==   "N "){

cout   < <   "System   is   now   back   to   menu.\n "   < <   endl;
system();
}
else{

cout   < <   "Please   input   Y   or   N! "   < <   endl;
system();
}
}
system();
}

void   nonsmoking_book(){

int   identify   =0;
for   (int   i=5;   i <10;){
if   (a[i]   ==   1)   i++;
else   {
a[i]   =   1;
cout   < <   "Congratulations!   You 've   book   nonsmoking   seat   successfully!\n "
  < <   "The   seat   NO.   is   "   < <   i   +   1   < <   ",   Please   enjoy   your   trip!\n "
  < <   endl;
identify   =   1;
break;
}
}
if   (identify   ==   0){

nonsmoking_booked   =   1;
if   (smoking_booked){

cout   < <   "We   are   so   sorry   that   all   of   our   tickets   had   sold   out.\n "
  < <   "Please   come   and   take   our   next   flight,   next   flight   leaves   in   3   hours.\n "
  < <   "Thank   you   for   using,   See   you   next   time!\n "   < <   endl;
system();
}
string   decision;
cout   < <   "We   are   sorry   to   tell   you   that   nonsmoking   seat   had   sold   out.\n "
  < <   "Would   you   please   change   to   smoking   seat?(Y/N) "   < <   endl;
cin   > >   decision;
if   (decision   ==   "Y ")   smoking_book();
else   if   (decision   ==   "N "){

cout   < <   "System   is   now   back   to   menu.\n "   < <   endl;
system();
}
else{

cout   < <   "Please   input   Y   or   N! "   < <   endl;
system();
}
}
system();
}

问题:在吸烟区座位满了以后程序提示是否转为非吸烟区,继续订非吸烟区的座位只能订到9号就提示座位已售完,不能订到10号座位;在非吸烟区座位订完后,程序直接输出座位已全部售完,不能转到吸烟区继续订座。在调试的时候我发现在第二种情况下尽管没调用smoking_book函数但是smoking_booked值仍然变成了1,请问这是什么原因?我觉得这就是问题的所在。我用Visual   Studio2005以及Visual   Studio   6调试均是这个问题。烦请各位大虾们花一点点宝贵的时间帮帮小弟~小弟新学的C++基础还不是很好~

[解决办法]
太长 先细看下
[解决办法]
int a[9] = {0};

===============

int a[10] = {0};

热点排行