Write a function that will take a vector of int values as


Please help with this gomework question.

Consider the problem of finding the pairs of integers in an input list that sum to 0. Assume that the integers are distinct. This problem is easily solved in quadratic time by doing a brute-force implementation with two (nested) loops that examines all possible pairs.

Write a function that will take a vector of int values as argument and it will return the pairs of values in that vector that sum to 0. Write a brute-forced implementation as described above.

The main program has been written for you, you just have to write the code for the findPairs function.

#include

#include

#include

#include

using namespace std;

vector findPairs(vector numbers){

}

int main(){

//create test vector to pass to the function

vector testNumbers;

testNumbers.push_back(1);

testNumbers.push_back(54);

testNumbers.push_back(2);

testNumbers.push_back(-3);

testNumbers.push_back(-2);

testNumbers.push_back(58);

testNumbers.push_back(-54);

testNumbers.push_back(58);

testNumbers.push_back(68);

testNumbers.push_back(78);

testNumbers.push_back(-75);

testNumbers.push_back(-1);

//call the function

vector pairs = findPairs(testNumbers);

//display results

for(int i=0;i

cout<

}

Request for Solution File

Ask an Expert for Answer!!
Computer Engineering: Write a function that will take a vector of int values as
Reference No:- TGS02889490

Expected delivery within 24 Hours