波音737座位哪里好
Problem statement:
问题陈述:
You and your friend are deciding to go for a tour by train. But before booking the ticket of the train, your friend asks you to book a ticket in such a way that both of you sit face to face.
您和您的朋友决定乘火车去游览。 但是在预订火车票之前,您的朋友要您以使双方都面对面的方式预订车票。
Seating decoration is known to you (given in the image) and you as a VIP customer are allowed to book seat number according to your choice.
座位装饰是您已知的(如图所示),您作为VIP客户可以根据您的选择预订座位号。
![ICP - Where is my seat?](https://www.includehelp.com/icp/Images/where-is-seat-icp.jpg)
After booking the ticket accordingly, your friend asks you, your seat number so that he can check which is his seat number and seat position (WS/MS/AS)?
相应地订票后,您的朋友会问您您的座位号,以便他可以检查他的座位号和座位位置(WS / MS / AS)?
Example:
例:
Input:
You have given your seat number N
Output:
Print your friend's seat number and seating position
WS: For Window Seat
MS: For Middle Seat
AS: For Aisle Seat
-----------------
Sample Input:
57
23
Sample Output:
52 AS
14 MS
Note: Before going to solution, we recommend you to try it by yourself first...
注意:建议您先尝试一下解决方案,然后再尝试解决方案...
Hint: Starting from bottom to top (1 to 6) sees the difference of opposite seat number, [11,9,7,5,3,1]
提示:从下至上(1到6)看到对面座位号的差异[11,9,7,5,3,1]
Algorithm:
算法:
1. Take input N
2. Switch (N%12)
2.1 Case 1: print N+11 and "WS"
2.2 Case 2: print N+9 and "MS"
2.3 Case 3: print N+7 and "AS"
2.4 Case 4: print N+5 and "AS"
2.5 Case 5: print N+3 and "MS"
2.6 Case 6: print N+1 and "WS"
2.7 Case 7: print N-1 and "WS"
2.8 Case 8: print N-3 and "MS"
2.9 Case 9: print N-5 and "AS"
2.10 Case 10: print N-7 and "AS"
2.11 Case 11: print N-9 and "MS"
2.12 Default : print N-11 and "WS"
3. END OF PROGRAM
Explanation:
说明:
Here we are finding mod of N (entered seat number) by 12 because there are 12 seats in a single cabin of the train. Now, if we divide it by 12 we will be able to identify each seat individually by its number, first 6 (1 to 6) are at the left side and next 6 (7 to 12) are at the right side.
在这里,我们发现N的模数(输入的座位号)为12,因为火车的单个机舱中有12个座位。 现在,如果将其除以12,我们将能够通过编号分别识别每个座位,前6个(1至6)在左侧,后6个(7至12)在右侧。
For example, if N=52 then, N%12=4, so 52nd seat will get a unique number in that particular cabin and it is at the left side.
例如,如果N = 52,然后,N%12 = 4,所以52 次座会得到在那个特定的车厢内的唯一的号码,它是在左侧。
Now, by seeing the given picture we can say that difference between seat number 1 and 12 is 11, 2 and 11 is 9 and so on, means its decreasing by two, starting from 11.
现在,通过查看给定的图片,我们可以说座位号1和12之间的差是11、2和11之间的差是9,依此类推,意味着座位号从11开始减少2。
So, for seat number 4 difference will be 5, that's why the opposite seat of 52 is 52+5=57.
因此,对于第4个座位,差异为5,这就是为什么52的对面座位为52 + 5 = 57的原因。
Similarly, for N=23, the mod value is 11, and the seat difference of the opposite seat will be 9. But in this case, we have to deduct 9 from N because N is at the right side. So, ans: is 23-9=14.
同样,对于N = 23, mod值为11,对面座位的座位差将为9。但是在这种情况下,由于N在右侧,因此我们必须从N中减去9。 因此,ans:是23-9 = 14 。
C++ implementation:
C ++实现:
#include <bits/stdc++.h>
using namespace std;
int main(){
int N;
//taking your seat number
cin>>N;
switch(N%12)
{
// Finding modulous of 12 because there are 12 seats in a cabin
// First 6 seats are at left side and next 6 seats (7 to 12)
//are at right side of a cabin
case 1:
cout<<N+11<<" WS";
break;
//if modulous is 2 then we can see that seat number is 2
case 2:
//so here the opposite seat is at right side and
//seat difference is 9
cout<<N+9<<" MS";
break;
case 3:
// here seat difference is 7 and opposite
//side is at right side
cout<<N+7<<" AS";
break;
case 4:
cout<<N+5<<" AS";
break;
case 5:
cout<<N+3<<" MS";
break;
case 6:
cout<<N+1<<" WS";
break;
// as said above seat number from 7 to 12 are at right side
// so opposite seat will be at left side and seat difference is 1
case 7:
cout<<N-1<<" WS";
break;
case 8:
cout<<N-3<<" MS";
break;
case 9:
cout<<N-5<<" AS";
break;
case 10:
cout<<N-7<<" AS";
break;
case 11:
cout<<N-9<<" MS";
break;
default:
cout<<N-11<<" WS";
break;
}
return 0;
}
Output
输出量
![ICP | where is seat output 1](https://i-blog.csdnimg.cn/blog_migrate/6374c19713fb03a4f47f8886d303069f.png)
![ICP | where is seat output 2](https://i-blog.csdnimg.cn/blog_migrate/e9e872c728533b3332e3e0b08635f66b.png)
波音737座位哪里好