Skip to content

Instantly share code, notes, and snippets.

@jitpaul
Created April 26, 2018 07:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jitpaul/7498eddf06af707c8b80609b240d2c4e to your computer and use it in GitHub Desktop.
Save jitpaul/7498eddf06af707c8b80609b240d2c4e to your computer and use it in GitHub Desktop.
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