Hello DdavidDLT,
The reason I'm starting here in loop i = 1 is because of previous code that forced me to do this way.
|
There is your first problem. Do not count on previous code to work here. The code you use in this program may have to be adjusted from the previous code.
Starting your variables "rKiek, gKiek and the others" at zero is fine and as it should be.
Your for loop
for(int i = 0; i < n; i++)
looks like it should work for now, but I have no idea where "n" came from, what it is fore, being a single letter instead of a better name, and its value.
"RGMJ[i]" tends to make me think that this is defined a constant array with values that can not be changed. is that true?
Sorry when I said "see the rest of the code" I should have said the whole program. Something that I can compile and see how it runs.
Right now there is to much guess work to make a program that runs and to duplicate the problems you are having.
Your if statement
if(gMas[i] + 1 == gMas[i + 1] || gMas[i + 1] - 1 == gMas[i])
. On the lhs of || you are taking the value of "gMas[i]" and adding one to this value then checking it against the next element of the array. On the rhs this is the opisit of the lhs. Having no idea what values are in "gMas" I do not know if this will ever work and my first thought is that it will never work.
I will see if I can work something up to test your code, but do not know if it will be the right way.
Hope that helps,
Andy
P.S. what we have here is the XY problem
http://xyproblem.info/ Please take a look.