Created
May 3, 2017 17:59
-
-
Save Gitmoko/79306f72034ecf9738765d52562821e6 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include<cmath> | |
#include<algorithm> | |
#include<vector> | |
#include<iostream> | |
#include<random> | |
constexpr auto CARDSMAX = 30u; | |
struct IncGenerator { | |
int current_; | |
IncGenerator (int start) : current_(start) {} | |
int operator() () { return current_++; } | |
}; | |
using namespace std; | |
int main(){ | |
std::vector<int> v(CARDSMAX) ; | |
IncGenerator g (0); | |
std::generate( v.begin(), v.end(), g); | |
std::random_device rdev{}; | |
std::mt19937 mt(rdev()); | |
std::shuffle(std::begin(v), std::end(v),mt); | |
std::vector<int> out; | |
for(int i = 0;i<10;i++){ | |
out.push_back(v[i]); | |
} | |
std::sort(std::begin(out),std::end(out)); | |
for(auto& e : out){ | |
std::cout << e+1 << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment