Java task

Employer
MichałPro
MichałPro
Description

JAVA Project Given a string of natural numbers, and a pointer P that initially points to the first element of the

in the string. Two operations are defined for this string:

ADD - adding an element with value X-1 to position P+1, and then moving the pointer P by X

elements to the right, where X is the value of the element located at position P.

DELETE - delete an element located at position P+1, and then move the P pointer

by X elements to the right, where X is the value of the deleted element.

When the P pointer points to an odd element, the ADD operation is performed, otherwise

case the DELETE operation is performed.

Moving the P pointer to the right is done in a cyclic manner, that is, the element next after the

the last element is the first element.

Determine the sequence of natural numbers formed after performing k operations on the input string.

Input:

Two lines, the first of which contains the number of operations (k), and the second contains the initial sequence of n natural numbers

natural numbers, in which successive elements are separated by a space character.

Output:

A string of natural numbers forming the solution to the task, in which successive elements are separated by a

separated by a space sign, printed out in a cyclic manner starting from the element pointed to by the indicator

... more to be discussed with the selected candidate

Published
on 2023-12-29
Category
File description 1
Zadanie do wykonania najlepiej do końca dnia.

Offers sent (6)

Budget
150.00 PLN
Copyright
-
Expires in
30 days