I want to be able to subtract or add the value of the index to the index so that the index move to the right or the left

Refresh

April 2019

Views

19 time

-2

I am writing a code in C++ and I want to add the value of the index to the index so that it shift the index either left or right.

user enters 13141118 and then i assign those number an index from 0 to 7.

index: 0 1 2 3 4 5 6 7 input: 1 3 1 4 1 1 1 8

and I want to add the value of index[0] which is 1 to get to the next index which is [1]. how would I do that? I want to add the number of the index to get to the next index.

so something like this

index[0]+1 to move to index[1]

the point is to get from the beginning to the end in the minimum amount of moves so the code would print out {0,1,4,3,7} base of the value that's how many moves you can go forward or back.

0 answers