关于基于Win32开发的模拟航空订票系统的有关问题
关于基于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();
系统要求:
程序显示下列菜单选项:
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();