It isn't really that challenging. All you need to do is track a little bit of information.
However, your problem statement is a little unclear. Is the following what you want?
Given file1 and file2:
for each (color + start_id):
is it "OK" in both file1 and file2?
|
If that is the case, your associative map should have the (color + start_id) as the key, and the number of "OK" instances as the value. Return true if the number of instances equals two (or more?).
Have you studied standard associative containers like
std::
map?
I am also at a loss when it comes to your data. How does your
p1 array correlate to file1 and file2? Are you reading the files like a CSV, where:
p1[record_number] == { ok, color, foo, start_id }
?
If that is the case, line 19 of your code should not
return true;
but instead it should increment a counter -- which tracks the number of times (priority + idString) associate with "OK". Only after either (after looping through all the records and the counter is >= 2) or (bumping the counter to a value of two) should you return true.
Hope this helps.