Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- /**
- * Finds the longest sequence out of every array and then returns the longest between them
- * @param int* arrays[] - an array that holds the addresses of the array to be checked
- * @param int arrays_length[] - an array that holds the lengths (sizes) of the arrays addresses
- * @param int size - size of the pointer arrays
- * @returns int - longest positive sequence found;0 if none
- */
- int getLongestSequenceFromArrays(int* arrays[], int arrays_length[], int size)
- {
- int i, *j,
- currentSequence, maxSequence = 0;
- for (i = 0; i < size; i++)
- {
- currentSequence = 0;
- for (j = arrays[i]; j < arrays[i] + arrays_length[i]; j++)
- if (*j > 0)
- {
- currentSequence++;
- if (currentSequence > maxSequence)
- maxSequence = currentSequence;
- }
- else
- currentSequence = 0;
- }
- return maxSequence;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement