Java Printing Hourglass __java

Source: Internet
Author: User

l1-002. Print an hourglass

The subject requires you to write a program that prints the given symbol in the shape of an hourglass. For example, given 17 "*", require printing in the following format

*****

***

*

***

*****

The so-called "hourglass shape" refers to the output of the odd number of symbols per line, the line symbol center alignment, the adjacent two lines of symbol number difference 2, the number of symbols from large to small order descending to 1, and then increasing in order from small to large, the number of the first sign is equal.

Given any n symbols, it is not necessarily possible to form an hourglass. Require that the printed hourglass can use as many symbols as possible.

Input Format:

The input gives 1 positive integers n (<=1000) and a symbol on one line, separated by a space in the middle.

output Format:

First print out the largest hourglass shape made up of a given symbol, and then output the number of symbols left unused in a single line.

Input Sample:

19 *

Output Sample:

*****

***

*

***

*****

2

Code:


Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.