Skip to content

Instantly share code, notes, and snippets.

@Gitmoko
Created May 3, 2017 17:59
Show Gist options
  • Save Gitmoko/79306f72034ecf9738765d52562821e6 to your computer and use it in GitHub Desktop.
Save Gitmoko/79306f72034ecf9738765d52562821e6 to your computer and use it in GitHub Desktop.
#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