Guest User

блять ся пятян

a guest
Feb 8th, 2021
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <vector>
  2. #include <bitset>
  3. #include <iostream>
  4. #include <algorithm>
  5.  
  6. using namespace std;
  7.  
  8. template <size_t N>
  9. bool count_compare(const bitset<N>& a, const bitset<N>& b){
  10.     return (a.count() < b.count());
  11. }
  12.  
  13. template <size_t N>
  14. bool operator<(const bitset<N>& a, const bitset<N>& b){
  15.     return (a.count() < b.count());
  16. }
  17.  
  18. int main(){
  19.     bitset<4> a (13);
  20.     bitset<4> b (14);
  21.     bitset<4> c (7);
  22.     bitset<4> d (8);
  23.     bitset<4> e (5);
  24.    
  25.     vector<bitset<4>> suka {a,b,c,d,e};
  26.    
  27.     cout << count_compare(a, e) << endl;
  28.     cout << (e < a) << endl;
  29.  
  30.     sort(begin(suka), end(suka));
  31.     sort(begin(suka), end(suka), count_compare);
  32.    
  33. }
Add Comment
Please, Sign In to add comment