Skip to content

Instantly share code, notes, and snippets.

@fpersson
Created August 28, 2012 20:18
Show Gist options
  • Save fpersson/3503709 to your computer and use it in GitHub Desktop.
Save fpersson/3503709 to your computer and use it in GitHub Desktop.
a c++ 11 dice
cmake_minimum_required (VERSION 2.8)
project(demo)
set(CMAKE_CXX_FLAGS "-Wall -std=c++0x")
add_executable(demo main.cpp)
target_link_libraries(demo )
#include <iostream>
#include <random>
#include <chrono>
int main () {
typedef std::chrono::high_resolution_clock tClock;
std::default_random_engine dre;
std::uniform_int_distribution<int> dice(1,6);
tClock::time_point begin = tClock::now();
tClock::duration d = tClock::now() - begin;
auto seed2 = d.count();
dre.seed(seed2);
for(int i=0; i< 10; i++){
std::cout << dice(dre) << " ";
}
std::cout << std::endl;
return 0;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment