Welcome to collectivesolver - Programming & Software Q&A. A website you can trust. All programs tested and works. Contact: aviboots(AT)netvision.net.il
GreenGeeks Web Hosting - Faster, Scalable & Eco-Friendly

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


8,120 questions

11,301 answers

573 users

How to get the number of pairwise matches between two vectors in C++

1 Answer

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

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

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

	int n = inner_product(v1.begin(), v1.end(), v2.begin(), 0, std::plus<>(), std::equal_to<>());

	cout << n << endl;

	return 0;
}

/*
run:

3

*/

 




answered Apr 24 by avibootz
...