bartekltg

wtfsort c++

Oct 18th, 2021 (edited)
318
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.53 KB | None | 0 0
  1. #include <string>
  2. #include <algorithm>
  3. #include <iostream>
  4. #include <vector>
  5. #include <random>
  6.  
  7. using namespace std;
  8.  
  9. int main(){
  10.  
  11.     const size_t N = 5000;
  12.     vector<int> tab(N);
  13.  
  14.     random_device rd;
  15.     mt19937_64 gen(rd());
  16.     uniform_int_distribution<int> dist;
  17.     generate(begin(tab),end(tab), [&](){return dist(gen);} );
  18.  
  19.  
  20.     for (auto &a: tab)
  21.         for (auto &b: tab)
  22.             if (a < b) swap(a,b);
  23.  
  24.  
  25.     if (is_sorted(begin(tab), end(tab)))
  26.         cout<<"sorted\n";
  27.     else cout<<"blah\n";
  28.  
  29. }
  30.  
Add Comment
Please, Sign In to add comment