Huawei OD machine test questions box zigzag arrangement, JAVA & Python & C & C++ & GO & JavaScript
topic
There are a batch of boxes (in the form of a string, set to str), and
it is required to place these boxes in the 之
order of the font from top to bottom in an open space with a width of n. Please output the location of the boxes.
For example: box ABCDEFG, the width of the open space is 3, the placement result is as shown in the figure:
Then the output is:
AFG
BE
CD
enter
Enter a line of strings, separated by spaces. The front part is a string str composed of letters or numbers, indicating the box; the
latter part is a number n, indicating the width of the open space. Example: ABCDEFG 3
output
The box placement result, as shown in the title example
example one
enter
ABCDEFG 3
output
AFG
BE
CD