find a sequence consecutive or not
Hello forum,
I am having trouble to formulate a simple algorithm.Check the following sequence:
1 2 3
|
s = {....... 4,5,6,7,8,9................}
|
How to find a sequnce that is consecutive or not ?
Thanks
1 2 3 4 5 6 7
|
for( some counter; counter < sequence.length(); ++counter )
{
if( sequence[counter] == sequence[counter+1] - 1)
do something
else
do another thing
}
|
Topic archived. No new replies allowed.