Created
August 28, 2012 20:18
-
-
Save fpersson/3503709 to your computer and use it in GitHub Desktop.
a c++ 11 dice
This file contains hidden or 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
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 ) |
This file contains hidden or 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 <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