And make sure you are aware of what you're checking. Making yourself a binary table is helpful:
1 && 1 && 1 = 1
1 && 1 && 0 = 0
1 && 0 && 1 = 0
1 && 0 && 0 = 0
0 && 1 && 1 = 0
0 && 1 && 0 = 0
0 && 0 && 1 = 0
0 && 0 && 0 = 0
(I know it's silly. ANYONE who's been programming of any length of time could have told you that, but it's a good exercise to be able to do for more complex examples.) As the table above shows you're ONLY going to pass (once you fix that little == problem) when ALL the conditions are true.
For some reason I feel this is a part of a larger program that will be testing more than this case. it may be useful for you to remember that in C/C++ true and false are really just 1 and 0, the sort you can do math with. Change the original line to:
and sum will hold the number of arrays where [q]==[i+1]. Or change it to:
sum = (a[q]==a[i+1]) + (b[q]==b[i+1]) + (c[q]==c[i+1]);
And you will have a unique number for each possible case based on binary numbers, IE 0 means no pass (000), 1 means the first passed (001), 2 means the second passed (010), 3 means the first and second passed (011), etc.
bsum = 1*(a[q]==a[i+1]) + 2*(b[q]==b[i+1]) + 4*(c[q]==c[i+1]);
Lots of possibilities.
But then again you may only want the case you showed us.