This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Need help with code: find longest repetitive sequence of numbers in array

Hello. I need help to find longest repetitive sequence of numbers in array and put that sequence in new array.

For example, I have array[10]={0,1,1,1,1,0,0,0,1,1} so the longest sequence will be 1,1,1,1 and this numer must be in new array. array1[4]={1,1,1,1}.

Thanks for your help!

Parents
  • The first problem is that that code is buggy as heck.  For starters, it has too many magic numbers, and way too few buffer index range checks.

    But the biggest problem is that your whole algorithm is wrong.  You say you want the longest sequence of repeated numbers, but you actually only count sequences of zeroes.

    And to top it all off, none of this has anything to do with Keil tools, so you're also asking this in the wrong place.

Reply
  • The first problem is that that code is buggy as heck.  For starters, it has too many magic numbers, and way too few buffer index range checks.

    But the biggest problem is that your whole algorithm is wrong.  You say you want the longest sequence of repeated numbers, but you actually only count sequences of zeroes.

    And to top it all off, none of this has anything to do with Keil tools, so you're also asking this in the wrong place.

Children
No data