Skip to content

Instantly share code, notes, and snippets.

Created April 26, 2018 07:04
What would you like to do?
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
vector<int>arr = {4,5,6,3,2};
/* Sort elements in descending order. */
sort(arr.begin(), arr.end(),
[](int&a, int&b)->bool{return a>b;});
/* Add 2 to all the elements of the array */
for_each(arr.begin(), arr.end(),
[](int& a){ a+=2;});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment