[Huawei OD machine test python] Digital reverse printing [2023 B volume | 100 points]

  [ Huawei OD Computer Test] - Real questions!! Click here! !
[ Huawei OD computer test] Classification of real test points!! Click here  !!

Topic description:

Xiaohua is a child who is very sensitive to numbers. He feels that the different arrangements of numbers have special beauty.

One day, Xiaohua had a sudden idea. If the numbers were arranged in multiple rows, with 1 number in the first row, 2 numbers in the second row, and 3 numbers in the third row,

That is, there are n numbers in the nth row, and the odd-numbered rows are arranged in positive order, the even-numbered rows are arranged in reverse order, and the numbers are accumulated in sequence.

Numbers arranged like this must be interesting. Are you smart enough to write code to help Xiaohua complete this idea?

The rules are summarized below:

a. Each number occupies 4 positions. If there are less than four digits, use '*' to fill them. For example, 1 is printed as 1***.

b. There are 4 adjacent spaces between numbers.

c. The printing order of numbers is alternately printed in forward and reverse order, with odd-numbered lines in forward order and even-numbered lines in reverse order.

d. The last line of numbers is in the top box, and the n-1th line is indented four spaces relative to the nth line.

Enter description:

The first line input is N, indicating how many lines to print; 1<=N<=30

Input: 2

Output description࿱

Guess you like

Origin blog.csdn.net/goldarmour/article/details/133364461