Home > Back-end >  Print the hourglass, each great god help answer with c language
Print the hourglass, each great god help answer with c language

Time:06-02

You are asked to write a program to bear on the given symbol print into the shape of an hourglass, given 17 "*", for example, requirements in the following format to print

* * * * *
* * *
*
* * *
* * * * *

"The hourglass shape", refers to the output an odd number of symbols per line; The center line all symbols; Adjacent two rows symbol number 2; Diminishing the number symbols from big to small order at first to 1, since the childhood again increasing order. The end is the same symbol.

Given any N symbols, can not form an hourglass, just asked to print out of the hourglass can drop as many symbols,

Input format:

Type in a line is given a positive integer N (1000) or less and a symbol, separated by Spaces in the middle,

The output format:

Print out the first largest hourglass shape consisting of a given symbol, the final output useless left off in a row the number of symbols,

Input the sample:

19 *

The output sample:

* * * * *
* * *
*
* * *
* * * * *
2

CodePudding user response:

I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10581430.html
I hope it can help you: https://blog.csdn.net/it_xiangqiang/category_10768339.html
  • Related