HUAWEI OD machine test real questions - digital reverse printing - 2023 OD unified test (B paper)

Title description:

Xiaohua is a child who is very sensitive to numbers. He thinks that the different arrangements of numbers have a special aesthetic feeling. One day, Xiaohua had a whim, if the numbers are arranged in multiple rows, there is 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, and the even-numbered rows are arranged in reverse order. The numbers arranged like this must be interesting. Smart, can you write code to help Xiaohua complete this idea?

The rules are summarized as follows:

a. Each number occupies 4 positions, if there are less than 4 digits, fill them with '*', such as 1 is printed as 1***.
b. There are 4 adjacent spaces between numbers.

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

d. The last line of numbers is the top grid, and line n-1 is indented by four spaces relative to line n

Enter a description:

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

Input: 2

Output description:

XXXX1***

3***XXXX2***

Supplementary note:

The symbol * indicates that the number is filled when the number is less than 4 digits, and the symbol X indicates the space between the numbers. Note that there is no need to print X during actual encoding, just print a space directly. Here is to explain the meaning of the question, so add X

Example 1

enter:

2

output:

    1***
3***    2***

illustrate:

#include <iostream>
using namespace std;

void pri

Guess you like

Origin blog.csdn.net/2301_76848549/article/details/131558665