Use double loop, digital output pyramid

1  / * 
2  *
 3  * Function: The digital input, digital output pyramid: the input is a few lines, the digital output of each row of the current row
 . 4  *
 . 5  *
 . 6  * @author: Apple.
 . 7  * @date: 2019 / the PM 1:25 11/23
 . 8  * / 
. 9          System.out.println ( "enter a number:" );
 10          int NUM = sc.nextInt ();
 . 11          // outer loop control line + number 
12 is          for ( int I . 1 =; i <NUM =; i ++ ) {
 13 is              // inner loop control space: row i-spaces. 1 NUM 
14              for ( int J =. 1; J <NUM = -i; J ++ ) {
 15                 Of System.out.print ( "" );
 16              }
 . 17              // number of control number of stars for each line of output arithmetic sequence, the law for the current row 2 * -1
 18 is              //          output is the current row 
. 19              for ( int K . 1 =; K <= (I * 2) -1; K ++ ) {
 20 is                  of System.out.print (I);
 21 is              } // wrap 
22 is              System.out.println ();
 23 is          }

 

Results are as follows:

 

Guess you like

Origin www.cnblogs.com/appleworld/p/11917661.html