Hi All,

First post here Would like some help for a short problem.

I have two arrays of the same size. I need to find if the difference of n consecutive elements of the two arrays are bigger than a certain threshold.

I have a rudimentary solution to this but was wondering if someone has a better and smarter solution. In the case of n=3, I am doing:

(Please ignore the part where I reach the end of the array. I have presented my problem to focus on the part above only)Code:for (int i = 0; i <= array_size; i++ ){ if ((a[i]-b[i] >= thresh ) && (a[i+1]-b[i+1] >= thresh) && (a[i+2]-b[i+2] >= thresh)) // do something }

As you can see, the conditional statement for the if is very poor design. If n = 10, I would have to write a very long expression.

Does someone have a better solution than mine?

Would appreciate your help.