7.18

                                    2017  D题 火车问题


Description
There is a famous railway station in PopPush City. Country there is incredibly hilly. The station was built in last century. Unfortunately, funds were extremely limited that time. It was possible to establish only a surface track. Moreover, it turned out that the station could be only a dead-end one (see picture) and due to lack of available space it could have only one track.

The local tradition is that every train arriving from the direction A continues in the direction B with coaches reorganized in some way. Assume that the train arriving from the direction A has N <= 1000 coaches numbered in increasing order 1, 2, ..., N. The chief for train reorganizations must know whether it is possible to marshal coaches continuing in the direction B so that their order will be a1, a2, ..., aN. Help him and write a program that decides whether it is possible to get the required order of coaches. You can assume that single coaches can be disconnected from the train before they enter the station and that they can move themselves until they are on the track in the direction B. You can also suppose that at any time there can be located as many coaches as necessary in the station. But once a coach has entered the station it cannot return to the track in the direction A and also once it has left the station in the direction B it cannot return back to the station.

Input
The input consists of blocks of lines. Each block except the last describes one train and possibly more requirements for its reorganization. In the first line of the block there is the integer N described above. In each of the next lines of the block there is a permutation of 1, 2, ..., N. The last line of the block contains just 0.

The last block consists of just one line containing 0.

Output
The output contains the lines corresponding to the lines with permutations in the input. A line of the output contains Yes if it is possible to marshal the coaches in the order required on the corresponding line of the input. Otherwise it contains No. In addition, there is one empty line after the lines corresponding to one block of the input. There is no line in the output corresponding to the last ``null'' block of the input.

Sample Input

5
1 2 3 4 5
5 4 1 2 3
0
6
6 5 4 3 2 1
0
0

Sample Output

Yes
No

Yes


 
源代码链接:点击打开链接

题目大意:给你一个数N,有1~N节按顺序排列的车厢
问你能否经过中转站C得到所指定的序列

思路: 中转站相当于一个栈,而达到指定序列有两种抢矿(1)一节一节出,即按原顺序到达B
                                                (2)先全部进栈,在全部出栈,即按逆序输出
             所以主要逻辑就是:

int a,b;
a=b=1;
 while(b<=n)
            {

                if(a==target[b])//(1)进去一个出来一个,即按顺序出站
                {
                    a++;
                    b++;
                }
                //(2)
                else if (!s.empty() && s.top()== target[b])//(2)和(3)判断逆序出站,并且如果中途顺序打乱转到(4)
                {
                    s.pop();
                    b++;
                }
                else if (a<=n)//(4)判断不满足条件的情况,即顺序打乱//逆序的话先进行压站把元素全部压完后再判断(2)操作是够完全逆序
                {
                    s.push(a);
                    a++;
                }
                else
                {
                    result=false;
                    break;
                }
            }
内容概要:集成测试是确保软件质量的关键环节,它在单元测试基础上验证模块间的交互和协作。文章详细介绍了集成测试的目的、重要性、流程步骤、策略与方法以及常见问题的解决办法。集成测试不仅验证模块接口的正确性,还确保系统的整体功能和性能符合预期。文章通过一个电商系统的实际案例,展示了集成测试在发现和解决问题中的具体应用。最后,展望了集成测试未来的发展趋势,如自动化测试、云计算、大数据和人工智能技术的应用。 适合人群:软件开发人员、测试工程师、项目经理及相关技术人员。 使用场景及目标:①了解集成测试在整个软件开发生命周期中的作用和重要性;②掌握集成测试的详细流程,包括测试计划制定、环境搭建、用例设计、执行与记录、缺陷管理和回归测试、测试总结与报告;③学习集成测试的不同策略(自顶向下、自底向上、混合策略)和方法(黑盒测试、白盒测试、模拟测试),并理解其适用场景;④掌握常见问题(接口不匹配、数据传递错误、性能瓶颈)的解决办法。 其他说明:本文不仅提供了集成测试的理论知识,还结合实际案例进行详细讲解,帮助读者更好地理解和应用集成测试技术。未来集成测试将受益于自动化测试、云计算、大数据和人工智能技术的发展,测试人员应不断学习新技术,优化测试流程,提高软件质量和效率。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值