第5周.翻煎饼

该博客介绍了一个关于煎饼翻转的问题,旨在通过一系列翻转操作将煎饼栈排序,使得最大煎饼在底部,最小煎饼在顶部。输入包含多个煎饼栈,每个栈由1到30个直径1到100的煎饼组成。输出需要给出翻转序列,以0结束。博主提供了解题思路,主要涉及寻找关键点和翻转操作,通过遍历数组找到最大值和最小值,通过特定操作将最大值移动到栈底,最小值移动到栈顶。
摘要由CSDN通过智能技术生成

[问题描述](老师已经为宝宝们翻译好啦)

Stacks and Queues are often considered the bread andbutter of data structures and find use in architecture, parsing,operating systems, and discrete event simulation.Stacks are also important in thetheory of formal languages.

堆栈和队列通常被认为是数据结构的面包和黄油,可用于体系结构、解析,操作系统和离散事件模拟。堆栈在形式语言理论中也很重要。

 

This problem involves both butter and sustenance inthe form of pancakes rather than bread in addition to a finicky server who flips pancakesaccording to a unique, but complete set of rules.

现在的问题涉及黄油和煎饼(而不是面包),同时还有一个根据唯一但完整的规则来翻煎饼的服务器。

 

Given a stack of pancakes, you are to write a programthat indicates how the stack can be sorted so that the largest pancake is on the bottom and thesmallest pancake is on the top.

给你一栈的煎饼,请你编写一个程序用于指示这个栈如何被排序以使得最大的煎饼在最下面而最小的煎饼在最上面。

 

The size of a pancake is given by the pancake’sdiameter.

煎饼的直径将被给出。

 

All pancakes in a stack have different diameters.

栈中的所有煎饼的直径都不一样。

 

Sorting a stack is done by a sequence of pancake“flips”.

对栈排序是通过一系列"翻转"来完成的。

 

A flip consists of inserting a spatula between twopancakes in a stack and flipping (reversing) all the pancakes on thespatula (reversing the sub-stack).

一次翻转的意思是:在两个煎饼之间插入铲子,然后将铲子上面的一堆煎饼整体翻过来。也就是指定一个位置,其上的子栈整体翻转。

 

A flip is specified by giving the position of thepancake on the bottom of the sub-stack to be flipped (relative to the whole stack).

翻转的位置将会被给出。

 

The pancake on the bottom of the whole stack hasposition 1

and the pancake on the top of a stack of n pancakeshas position n.

位置是这样定义的:栈底编号为1,栈顶编号为n

 

A

  • 2
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值