Messy and hacky, should use set rather than map. In reality should use a hash…
#include <vector>
#include <map>
using namespace std;
int main() {
vector<int> array;
array.push_back(1);
array.push_back(10);
array.push_back(5);
map<int,int> exists;
for(size_t n=0;n<array.size();n++) {
exists[array[n]] = 1;
}
for(size_t n=0;n<array.size();n++) {
int value_needed = 15-array[n];
if(exists[value_needed] == 1) cout << "pair: " << array[n] << " " << value_needed << endl;
}
}