Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <bitset>
- #include <iostream>
- #include <algorithm>
- using namespace std;
- template <size_t N>
- bool count_compare(const bitset<N>& a, const bitset<N>& b){
- return (a.count() < b.count());
- }
- template <size_t N>
- bool operator<(const bitset<N>& a, const bitset<N>& b){
- return (a.count() < b.count());
- }
- int main(){
- bitset<4> a (13);
- bitset<4> b (14);
- bitset<4> c (7);
- bitset<4> d (8);
- bitset<4> e (5);
- vector<bitset<4>> suka {a,b,c,d,e};
- cout << count_compare(a, e) << endl;
- cout << (e < a) << endl;
- sort(begin(suka), end(suka));
- sort(begin(suka), end(suka), count_compare);
- }
Add Comment
Please, Sign In to add comment