航空机票预订c#代码_航空公司座位预订问题的C ++程序

航空机票预订c#代码

Problem statement: Write a program to assign passengers seats in an airplane. Assume a small airplane with seat numbering as follows:

问题陈述:编写一个程序来分配飞机上的乘客座位。 假设小型飞机的座位编号如下:

    1 A B C D
    2 A B C D
    3 A B C D
    4 A B C D
    5 A B C D
    6 A B C D
    7 A B C D

The program should display the seat pattern, with an ‘X’ marking the seats already assigned. After displaying the seats available, the program prompts the seat desired, the user types in a seat, and then the display of available seats is updated. This continues until all seats are filled or until the user signals that the program should end. If the user types in a seat that is already assigned, the program should say that the seat is occupied and ask for another choice.

程序应显示座位模式,并带有“ X”标记已分配的座位。 在显示可用座位之后,程序会提示所需的座位,用户键入座位,然后更新可用座位的显示。 这一直持续到所有座位都装满或用户发出程序结束的信号为止。 如果用户键入已经分配的座位,则程序应说明该座位已被占用,并要求其他选择。

Input Example:

输入示例:

For example, after seats 1A, 2B, and 4C are taken, the display should look like:

例如,在坐下了座位1A,2B和4C之后,显示屏应如下所示:

    1 X B C D
    2 A X C D
    3 A B C D
    4 A B X D
    5 A B C D
    6 A B C D
    7 A B C D

Solution

The whole problem can be implemented with help of 4 major functions:

可以通过以下四个主要功能来实现整个问题:

  1. getData()

    getData()

  2. display()

    显示()

  3. check()

    check()

  4. update()

    update()

The entire problem is discussed dividing into parts focusing on functional modularity.

讨论了整个问题,分为针对功能模块化的部分。

1. Initialize a 2-D array to represent the seat matrix

1.初始化一个二维数组以表示座位矩阵

A 2-D character array is used to represent the seat matrix where the first column have the row number of each seat & the rest of the columns have four seat A,B,C,D respectively. Thus it’s a 7X5 2-D array to represent the airplane seat matrix which looks like fo

  • 0
    点赞
  • 6
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值