#include <iostream>
#include <numeric>
using namespace std;
string combine(const string &x, const string &y)
{
return "("+x+","+y+")";
}
string concatenate(const string &x,const string &y)
{
if(x.empty())
{
return y;
}
return x+", "+y;
}
int main(void)
{
int arr1[] = {1, 3, 9, 4} ;
int arr2[] = {1, 1, 1, 2} ;
int totalValue = inner_product(arr1, arr1 + sizeof (arr1) / sizeof (*arr1), arr2, 0);
cout << totalValue << endl ;
totalValue = inner_product(arr1, arr1 + sizeof (arr1) / sizeof (*arr1), arr2, 0, plus<int> (), multiplies<int> ()) ;
cout << totalValue << endl ;
string s1[] = {"if","string","sort"};
string s2[] = {"keyword","library type","algorithm"};
cout << inner_product(s1, s1 + sizeof(s1) / sizeof(*s1), s2, string(), concatenate, combine) << endl;
return 0;
}
inner_productd的用法
最新推荐文章于 2021-01-28 08:42:51 发布