Linux Shell Programming print shape programming ideas

Disclaimer: This article is a blogger original article, follow the CC 4.0 BY-SA copyright agreement, reproduced, please attach the original source link and this statement.
This link: https://blog.csdn.net/shuai0845/article/details/86532420

Print shape programming ideas:
let the shape of regular programming is nothing more than control of rows and columns, the use of dual or multiple write cycles
such as printing a shape

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

An outer loop control line, the control loop within the column
Here Insert Picture Description
, for example, printing a shape

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

Here Insert Picture Description
A shape like

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

Still the outer-loop control lines, the inner loop control column, but the output is not within a loop , and in still output spaces before
a total of six lines, the last line is not output spaces, a fifth line space. . . A law of space is found and so the number of rows the number of rows minus
and *is, a first row *, second row three *, of Law 2i-1 th *, i is the row
programming below
Here Insert Picture Description
as a shape

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

And much like the shape and the last, only need to control a line on the line, the line will reverse the output
Here Insert Picture Description
to write a Shell program, a print by the " *" side length is composed of 8 equilateral triangle upright on behalf of (a side length asterisk one unit). Shape as

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

The shape and the like above. Is a *followed by a space directly *+空格as a whole
C language programming as
Here Insert Picture Description
an important programming ideas, just know that these ideas, either shell or the only C language or Java language syntax is just not the same, for example,

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

The shape of the shell programming shell written as follows
Here Insert Picture Description

Guess you like

Origin blog.csdn.net/shuai0845/article/details/86532420