Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
Hostgator 1 Penny

BlueHost Web Hosting

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

Ecommerce Software - Best Ecommerce Platform Made for You - Free Trial

getflywheel wordpress hosting


Distribute your Resume to 500+ Job Boards & Recruiters


7,621 questions

10,674 answers

573 users

How to implement pairwise matches between two vectors in C++

1 Answer

0 votes
#include <iostream>  
#include <vector> 

using std::vector;
using std::cout;  
using std::endl;

int pairwise_matches(vector<int> v1, vector<int> &v2)
{
	int sum = 0;

	for (int i = 0; i < v1.size(); i++)
		if (v1[i] == v2[i])
			sum++;

	return sum;
}

int main()
{
	vector<int> v1{ 0, 1, 2, 3, 4 }, v2{ 5, 1, 2, 6, 4 };

	cout << pairwise_matches(v1, v2) << endl;

	return 0;
}

/*
run:

3

*/

 




answered Apr 25 by avibootz
...