#include<algorithm>
#include<vector>
#include<iostream>
using namespace std;
int main(){
vector <int> a{ 1, 2, 3, 4, 5}, b( a), c( a.size());
//二元函数对应的lambda表达式
transform( a.begin(), a.end(), b.begin(), c.begin(),[](int a, int b){
return a*b;
});
for(auto p = c.begin(); p != c.end(); p ++)
cout << *p << ' ';
}
C++ 二元函数对应的lambda表达式
最新推荐文章于 2023-01-12 18:23:20 发布