arnex

TRvi

Apr 2nd, 2012
41
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.18 KB | None | 0 0
  1. // next_permutation
  2. #include <iostream>
  3. #include <algorithm>
  4. #include <vector>
  5.  
  6. #define pb push_back
  7. #define TRvi(it,v) for(vector<int>::iterator it = v.begin(); it != v.end(); it++)
  8. #define all(x) x.begin(), x.end()
  9.  
  10. using namespace std;
  11.  
  12. int main() {
  13. // int myints[] = {1, 2, 3, 4, 5, 6, 7 , 8};
  14. // cout << "The 3! possible permutations with 3 elements:\n";
  15. // //sort (myints, myints + 3);
  16. //
  17. // do {
  18. // cout << myints[0] << " " << myints[1] << " " << myints[2] << endl;
  19. // } while (next_permutation(myints, myints + 8));
  20.  
  21. // cout << (1 << 1) << endl;
  22. // cout << (1 << 2) << endl;
  23. // cout << (1 << 3) << endl;
  24. // cout << (1 << 4) << endl;
  25. // cout << (1 << 5) << endl;
  26. // cout << (1 << 6) << endl;
  27. // cout << (1 << 7) << endl;
  28. // cout << (1 << 8) << endl;
  29. // cout << (1 << 16) << endl;
  30.  
  31. // for (int i = 0; i <= 100; i++) {
  32. // cout << i << " " << (i&1) << endl;
  33. // }
  34.  
  35. vector<int> v;
  36. v.pb(3);
  37. v.pb(4);
  38. v.pb(1);
  39. v.pb(6);
  40. TRvi(i, v)
  41. cout << *i << " ";
  42. cout << endl;
  43. sort(all(v));
  44. TRvi(i, v)
  45. cout << *i << " ";
  46. return 0;
  47. }
Add Comment
Please, Sign In to add comment