Created
May 23, 2016 21:35
-
-
Save steveobbayi/6809b47e322920efe486cc43c4b20d88 to your computer and use it in GitHub Desktop.
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
vector<int> src = {2,5,3}; // our source of data | |
vector<int> src2 = {7,8,9}; // 2nd source of data | |
vector<int> dest = {0,0,0,0,0,0,0,0,0,0}; // array to be modified | |
// Lets exchange contents of src and src2 | |
swap_rages(src.begin(), src.end(),src2.begin()); | |
// src2 is now contents of src while | |
// src is now contents or src2 | |
//lets move src to the end of dest assuming its redefined | |
fill(dest.begin(), dest.end(),1); | |
//all elements in dest are now 1 | |
//replace all occurences of 6 with 5 | |
replace(src.begin(), src.end(),6,5); | |
//remove all occurences of 7 | |
remove(src.begin(), src.end(),7); | |
//remove consequent equal elements | |
unique(src.begin(), src.end()); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment