-
-
Save jitpaul/7498eddf06af707c8b80609b240d2c4e to your computer and use it in GitHub Desktop.
BlogSnippets
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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