Files
PAT/source/html/b1027.html
T

25 lines
1.4 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
打印沙漏
<div class="ques-view"><p>本题要求你写个程序把给定的符号打印成沙漏的形状。例如给定17个“*”,要求按下列格式打印</p>
<pre><code>*****
***
*
***
*****
</code></pre><p>所谓“沙漏形状”,是指每行输出奇数个符号;各行符号中心对齐;相邻两行符号数差2;符号数先从大到小顺序递减到1,再从小到大顺序递增;首尾符号数相等。</p>
<p>给定任意N个符号,不一定能正好组成一个沙漏。要求打印出的沙漏能用掉尽可能多的符号。</p>
<h3 id="-">输入格式:</h3>
<p>输入在一行给出1个正整数N(<span class="katex"><span class="katex-mathml"><math><mrow><mo>≤</mo></mrow>\le</math></span><span aria-hidden="true" class="katex-html"><span class="strut" style="height:0.63597em;"></span><span class="strut bottom" style="height:0.7719400000000001em;vertical-align:-0.13597em;"></span><span class="base textstyle uncramped"><span class="mrel">≤</span></span></span></span>1000)和一个符号,中间以空格分隔。</p>
<h3 id="-">输出格式:</h3>
<p>首先打印出由给定符号组成的最大的沙漏形状,最后在一行中输出剩下没用掉的符号数。</p>
<h3 id="-">输入样例:</h3>
<pre><code class="lang-in">19 *
</code></pre>
<h3 id="-">输出样例:</h3>
<pre><code class="lang-out">*****
***
*
***
*****
2
</code></pre>
</div>