Huawei OD machine test-MP3 cursor position (C++ & Java & JS & Python)

describe

Because the screen of MP3 Player is small, only a few songs can be displayed on each screen when displaying the song list. Users have to use the up and down keys to browse all songs. In order to simplify the process, it is assumed that each screen can only display 4 songs, and the initial position of the cursor is the first song.

Now we want to use the up and down keys to control the movement of the cursor to browse the song list. The control logic is as follows:

  1. When the total number of songs <= 4, there is no need to turn the page, just move the cursor position.

When the cursor is on the first song, press the Up key to move the cursor to the last song; when the cursor is on the last song, press the Down key to move the cursor to the first song.

In other cases, when the user presses the Up key, the cursor moves to the previous song; when the user presses the Down key, the cursor moves to the next song.

2. When the total number of songs is greater than 4 (taking a total of 10 songs as an example):

Special page turning: When the screen displays the first page (that is, songs 1 to 4 are displayed), the cursor is on the first song, and after the user presses the Up key, the screen will display the last page (that is, songs 7 to 10 are displayed) song), and the cursor is placed on the last song. Similarly, when the screen displays the last page, the cursor is on the last song

Guess you like

Origin blog.csdn.net/m0_68036862/article/details/132850401