Skip to content

Instantly share code, notes, and snippets.

@jitpaul

jitpaul/BlogSnippets Secret

Created Apr 26, 2018
Embed
What would you like to do?
BlogSnippets
#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