芜湖哪些公司做公司网站/排名轻松seo 网站

芜湖哪些公司做公司网站,排名轻松seo 网站,保山市住房和城乡建设局门户网站,做电商网站需要的证航空机票预订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…

航空机票预订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 following:

2-D字符数组用于表示席位矩阵,其中第一列具有每个席位的行号,其余列分别具有四个席位A,B,C,D。 因此,它是一个7X5二维数组,表示飞机座椅矩阵,如下所示:

airline reseravtion system in C++

2. Take user input for seat no

2.接受用户输入的座位号

User is requested to input the desired seat no by giving corresponding no of seat. Like a valid seat no is 1A, 3C, 7D and so on, whereas, an invalid seat request can be 6F, 0B so on.

要求用户通过提供相应的座位号来输入所需的座位号。 像有效席位一样,no是1A,3C,7D等,而无效席位请求可以是6F,0B等。

The input is taken by our function getData() which takes user input & returns the string.

输入由我们的函数getData()获得 ,该函数接受用户输入并返回字符串。

3. Check the seat no request (check() )

3.检查座位无要求(check())

Our major function for this problem is to check the validity of the seat request & update seat matrix status as per request.

我们针对该问题的主要功能是检查座位请求的有效性并根据请求更新座位矩阵状态。

  • Firstly it checks whether the user input is in the range 1A to 7D or not. If user input is out of range a prompt out "invalid request" & continue for further request.

    首先,它检查用户输入是否在1A到7D范围内。 如果用户输入超出范围,则提示“无效请求”并继续进行进一步的请求。

  • Check whether user input is 'N' or not. If it's 'N' then user wants to end the program. Terminate.

    检查用户输入是否为“ N” 。 如果为“ N”,则用户要结束程序。 终止。

  • if seat request is valid but already occupied

    如果座位请求有效但已被占用

    Then prompt a message stating “It’s already occupied”

    然后提示信息“已被占用”

    This checking can be done by founding the 2-D array row & column index for the corresponding seat.

    可以通过找到相应座位的二维数组行和列索引来完成此检查。

    Let,

    让,

    row_index=r&column_index=c
    If(seat_matrix[row_index][column_index]==’X’)

    row_index = r&column_index = c
    如果(seat_matrix [row_index] [column_index] =='X')

    Seat is occupied.

    座位已满。

  • ELSE seat request is a valid one and not occupied still

    ELSE座位请求是有效的,尚未占用

    Update()

    更新()

4. Update the valid entry

4.更新有效条目

If the request is to update the valid seat we simple change its value to 'X'. It can be done by finding row & column index and updating the value of seat_matrix at that location to 'X'.

如果请求更新有效席位,我们只需将其值更改为'X'即可 。 可以通过查找行和列索引并将该位置的seat_matrix值更新为'X'来完成

5. Special function to check whether all seats are occupied

5.特殊功能,检查是否所有座位都被占用

The program also need to be terminated when all seats are occupied. Thus every time we keep a checking whether all the entry of seat_matrix is 'X' or not.

当所有座位都坐满时,还需要终止该程序。 因此,每次我们都检查一下seat_matrix的所有条目是否为“ X”

航空公司座位预订问题的C ++实现 (C++ implementation for Airline Seat Reservation Problem)

#include <bits/stdc++.h>
using namespace std;
// to check whether all sits are occupied or not
int allOccupied(char arr[7][5]){ 
int count=0;
for(int i=0;i<7;i++){
for(int j=1;j<5;j++)
if(arr[i][j]=='X')
count++;
}
if(count==28)
return 1;
return 0;
}
//to display the sits
void display(char arr[7][5]){ 
for(int i=0;i<7;i++){
for(int j=0;j<5;j++){
cout<<arr[i][j]<<" ";
}
cout<<endl;
}
return;
}
//take user data
string getData(){ 
string p;
cout<<"enter valid seat no to check(like 1B) or N to end: ";
cin>>p;
return p;
}
//update sit status
void update(char arr[7][5],int row,int col){ 
cout<<"congrats, your seat is valid. Reserved for you\n";
cout<<"updated seat status..........\n";
arr[row][col]='X';
}
//checking whether user request for 
//his sit no can be processed or not
int check(char arr[7][5],string s){ 
//if user input is not in the range 1A to 7D
if(s[0]>'7' || s[0]<'1' || s[1]>'D' || s[1]<'A'){ 
cout<<"invalid seat no\n"; //invalid sit no
return 0;
}
int row=-1,col=-1;
//find the row no of the user sit
for(int i=0;i<7;i++){
if(arr[i][0]==s[0])
row=i;
}
//find the column no of user sit
for(int j=0;j<5;j++){
if(arr[row][j]==s[1])
col=j;
}
//check whether sit is already occupied or not.
if(col==-1){
cout<<"Seat is already occupied\n";
return 0;
}
else{
//if it's a valid sit & not occupied, 
//process the requested & update the sit as occupied 
update(arr,row,col);   
}
return 1;
} 
void airline(char arr[7][5]){
// user can stop process by pressing 'N'
cout<<"enter N if you are done!\n"; 
string s;
// continue if not interrepted by user or 
//there is valid sit in unoccupied state
while(true){ 
s=getData(); //get user input
//if user input is to stop the process
if(s[0]=='N') 
break; // break
//process the request & check according to
if(check(arr,s)) 
display(arr);
if(allOccupied(arr)){ //if all sits are occupied
cout<<"sorry, no more seats left!!!!!!!!!!1..."<<endl;
break; //break
}
}
cout<<"Thanks, that's all"<<endl; //end of program
}
int main()
{
//2-D array for storing sit number
char arr[7][5]; 
for(int i=0;i<7;i++){
//forst column is row number
arr[i][0]=i+1+'0';
for(int j=1;j<5;j++){
//to represent sit number A,B,C,D respectively
arr[i][j]='A'+j-1; 
}
}
cout<<"initial seat arrangements........\n";
display(arr);
airline(arr); //airline function
return 0;
}

Output

输出量

initial seat arrangements........
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
enter N if you are done!
enter valid seat no to check(like 1B) or N to end: 2B 
congrats, your seat is valid. Reserved for you  
updated seat status.......... 
1 A B C D
2 A X 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
enter valid seat no to check(like 1B) or N to end: 3C 
congrats, your seat is valid. Reserved for you  
updated seat status.......... 
1 A B C D
2 A X C D
3 A B X D
4 A B C D
5 A B C D
6 A B C D
7 A B C D
enter valid seat no to check(like 1B) or N to end: 2B 
Seat is already occupied
enter valid seat no to check(like 1B) or N to end: 7E 
invalid seat no
enter valid seat no to check(like 1B) or N to end: 7C 
congrats, your seat is valid. Reserved for you  
updated seat status.......... 
1 A B C D
2 A X C D
3 A B X D
4 A B C D
5 A B C D
6 A B C D
7 A B X D
enter valid seat no to check(like 1B) or N to end: N  
Thanks, that's all  

翻译自: https://www.includehelp.com/cpp-programs/airline-seat-reservation-problem.aspx

航空机票预订c#代码

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/541825.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

linux命令之which

which这个命令可以说并不常用&#xff0c;它的作用是查看可执行文件的位置&#xff0c;并返回第一个搜索结果。可执行文件也就是指的某个系统命令&#xff0c;但是这个命令的位置必须是在PATH路径里存在的。截图中 &#xff0c;pwd的位置在/bin/pwd,当然&#xff0c;这个路径是…

线性代数向量乘法_向量的标量乘法| 使用Python的线性代数

线性代数向量乘法Prerequisite: Linear Algebra | Defining a Vector 先决条件&#xff1a; 线性代数| 定义向量 Linear algebra is the branch of mathematics concerning linear equations by using vector spaces and through matrices. In other words, a vector is a mat…

html的学习思维导图

转载于:https://www.cnblogs.com/lingdublog/p/6438088.html

cubic-bezier_带CSS中的示例的cube-bezier()函数

cubic-bezierIntroduction: 介绍&#xff1a; How many times have we come across the word function? Well, it would not be wrong to say a lot. The fact that functions are used in web development while developing a website or web page is very important. There…

上手Caffe(一)

author&#xff1a;oneBite 本文记录编译使用caffe for windows 使用环境 VS2013 ultimate,win7 sp1,caffe-windows源码&#xff08;从github上下载caffe的windows分支&#xff0c;下载解压之后&#xff0c;不要改变原有的目录结构,因为solution rebuild时会使用文件的相对路径…

关于设置不同linux主机之间ssh免密登录简易方法

2019独角兽企业重金招聘Python工程师标准>>> 在linux日常中&#xff0c;经常会有ssh链接其他主机服务器的action,也学习过大家日常用配置ssh免密登录的方法。 小编今天在这里给大家介绍一种比较简单的配置linux主机ssh免密登录的方法。 两台主机的IP地址&#xff1a…

java自定义线程池池,线程池使用及自定义线程池

一 案例引申编写代码同时只允许五个线程并发访问(以下文的函数为例子)private static void method() {System.out.println("ThreadName" Thread.currentThread().getName() "进来了");Thread.sleep(2000);System.out.println("ThreadName" Th…

impala和mysql语法,impala CREATE TABLE语句

CREATE TABLE语句用于在Impala中的所需数据库中创建新表。 创建基本表涉及命名表并定义其列和每列的数据类型。语法以下是CREATE TABLE语句的语法。 这里&#xff0c;IF NOT EXISTS是一个可选的子句。 如果使用此子句&#xff0c;则只有在指定数据库中没有具有相同名称的现有表…

Java二维数组谷电,java二维数组遍历的2种代码

二维数组遍历&#xff1a;思想&#xff1a;1.先将二维数组中所有的元素拿到2.再将二维数组中每个元素进行遍历&#xff0c;相当于就是在遍历一个一维数组第一种方法&#xff1a;双重for循环//遍历二维数组public class Traverse_a_two_dimensional_array {public static void m…

MATLAB元胞自动机报告,元胞自动机概述与MATLAB实现

什么是元胞自动机&#xff1f;元胞自动机(cellular automata&#xff0c;CA) 是一种时间、空间、状态都离散&#xff0c;空间相互作用和时间因果关系为局部的网格动力学模型&#xff0c;具有模拟复杂系统时空演化过程的能力。它能构建随时间推移发生状态转移的系统&#xff0c;…

php session redis db,php session redis 配置

具体环境&#xff1a;一台apachephp的服务器(yum安装remi源及配置 httpd-2.2.15 php-5.4.45)一台redis服务器(yum安装remi源及配置 redis-3.2.6)保证apache服务器可以访问redis服务器的6379端口具体步骤&#xff1a;1、在apachephp服务器上安装redis扩展点击(此处)折叠或打开yu…

(四)其他的说明

2019独角兽企业重金招聘Python工程师标准>>> 关于日志&#xff0c;主要是利用aop来实现的。cn.demoframe.test.frame.service.LogAspect&#xff0c;这里在方法前做了个切面setReqReachTime&#xff0c;设置了一个请求达到时间。接下来还有个切面&#xff0c;是在co…

vm中linux物理内存不足解决方案

为什么80%的码农都做不了架构师&#xff1f;>>> 之前创建的一个center os,默认是8GB&#xff0c;经过一顿折磨&#xff0c;装jdk,tomcat,redis,mycat,nginx,mysql,hadoop...终于&#xff0c;内存不足了&#xff0c;在使用docker build某镜像的时候。迭代懵逼了&am…

.7z.001,.7z.002这样的文件如何解压

1 如图所示&#xff0c;压缩分卷没有显示关联的软件来打开&#xff0c;Winrar右击也无法解压 2 可以使用7-ZIP软件打开该文件&#xff0c;然后选择提取&#xff08;相当于Winrar的解压&#xff09;&#xff0c;然后选择提取路径&#xff0c;默认是同一个文件夹&#xff0c;点击…

php中文网视频放不了,【杂谈】看php中文网视频课程的正确姿势!

看在线课程如何集中精力学习&#xff1f;ki4网为你分享看ki4网视频课程的正确姿势&#xff01;不谈理论给些实用建议&#xff0c;可以根据你的情况多尝试&#xff0c;看看哪条对你有用&#xff01;1、选一门自己有兴趣而且教师讲得好的课程。(点击学习&#xff1a;ki4网视频教程…

怎么查看我的php版本,怎样查看php版本

怎样查看php版本方法一&#xff1a;命令行查询如果已经配置好环境变量&#xff0c;直接在命令行中输入php -v&#xff0c;将会显示php的版本信息。如果没有配置环境变量&#xff0c;直接在命令行中进入到php的安装目录后&#xff0c;再输入命令php -v&#xff0c;如图所示是我在…

xor在PHP是什么意思,?=‘在PHP中是什么意思?

万千封印因为它不会增加任何价值echo&#xff0c;我认为您希望了解PHP中的确切含义&#xff1a;Array([0] > Array([0] > 368 // T_OPEN_TAG_WITH_ECHO[1] > [2] > 1)[1] > Array([0] > 309 // T_VARIABLE[1] > $a [2] > 1)[2] > ; // U…

如何使用ES6中的参数

ECMAScript 6&#xff08;或者叫 ECMAScript 2015&#xff09;是 ECMAScript 的最新标准&#xff0c;极大的提高了 JavaScript 中处理参数的能力。现在我们可以使用 rest 参数&#xff08;rest parameters&#xff09;、默认值&#xff08;default values&#xff09;和解构&am…

php 代码 自动检查工具下载,PHP_CodeSniffer安装和使用教程(自动代码检查规范工具)...

在我们开发中都会讲究代码规范&#xff0c;若是个人开发者&#xff0c;代码规范与否&#xff0c;只要自己看得懂便可以了&#xff0c;但是在团队协作中&#xff0c;代码规定尤为重要&#xff0c;下面&#xff0c;我们介绍一款PHP_CodeSniffer&#xff0c;自动检查代码规范的工具…

在Bootstrap中使用类的按钮类型

Bootstrap has 7 different types of buttons with contextual classes from which we can create buttons easily by using these classes (.btn-default, .btn-success, .btn-danger, .btn-primary, .btn-info, .btn-warning, .btn-link). Bootstrap具有上下文类型的 7种不同…