Comparing Arrays
in
Programming Questions
•
2 years ago
Hello.
I need to compare two arrays of ints of the same length and fill a third array with the results.
The rules of the comparison are as follows:
if arrayA[x] = arrayB[x] then arrayC[x] = 2.
if arrayA[x] = arrayB[not x] then arrayC[x] = 1.
if arrayA[x] is not in arrayB at all, then arrayC[x] = 0.
So {1,3,3,5,4} and {3,2,5,4,4} would return {0,1,0,1,2}.
Any ideas on the best way to set this up are most welcome.
I need to compare two arrays of ints of the same length and fill a third array with the results.
The rules of the comparison are as follows:
if arrayA[x] = arrayB[x] then arrayC[x] = 2.
if arrayA[x] = arrayB[not x] then arrayC[x] = 1.
if arrayA[x] is not in arrayB at all, then arrayC[x] = 0.
So {1,3,3,5,4} and {3,2,5,4,4} would return {0,1,0,1,2}.
Any ideas on the best way to set this up are most welcome.
1