Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // next_permutation
- #include <iostream>
- #include <algorithm>
- #include <vector>
- #define pb push_back
- #define TRvi(it,v) for(vector<int>::iterator it = v.begin(); it != v.end(); it++)
- #define all(x) x.begin(), x.end()
- using namespace std;
- int main() {
- // int myints[] = {1, 2, 3, 4, 5, 6, 7 , 8};
- // cout << "The 3! possible permutations with 3 elements:\n";
- // //sort (myints, myints + 3);
- //
- // do {
- // cout << myints[0] << " " << myints[1] << " " << myints[2] << endl;
- // } while (next_permutation(myints, myints + 8));
- // cout << (1 << 1) << endl;
- // cout << (1 << 2) << endl;
- // cout << (1 << 3) << endl;
- // cout << (1 << 4) << endl;
- // cout << (1 << 5) << endl;
- // cout << (1 << 6) << endl;
- // cout << (1 << 7) << endl;
- // cout << (1 << 8) << endl;
- // cout << (1 << 16) << endl;
- // for (int i = 0; i <= 100; i++) {
- // cout << i << " " << (i&1) << endl;
- // }
- vector<int> v;
- v.pb(3);
- v.pb(4);
- v.pb(1);
- v.pb(6);
- TRvi(i, v)
- cout << *i << " ";
- cout << endl;
- sort(all(v));
- TRvi(i, v)
- cout << *i << " ";
- return 0;
- }
Add Comment
Please, Sign In to add comment