Advertisement
cd62131

vector to list

Mar 5th, 2014
330
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.64 KB | None | 0 0
  1. #include <algorithm>
  2. #include <iostream>
  3. #include <list>
  4. #include <vector>
  5. using namespace std;
  6. enum class knum { zero, one, two, three, four, five, six, seven, eight, nine, ten };
  7. const int knumCount = 11;
  8. int main() {
  9.   vector<knum> tagVector = {knum::zero, knum::one, knum::two, knum::three, knum::four,
  10.     knum::five, knum::six, knum::seven, knum::eight, knum::nine, knum::ten};
  11.   random_shuffle(tagVector.begin(), tagVector.end());
  12.   for (auto& e: tagVector) cout << (int )e << ' '; cout << endl;
  13.   list<knum> tagList;
  14.   tagList.assign(tagVector.begin(), tagVector.end());
  15.   for (auto& e: tagList) cout << (int )e << ' '; cout << endl;
  16. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement