Created
February 6, 2013 13:47
-
-
Save belltailjp/4722583 to your computer and use it in GitHub Desktop.
C++11のstd::discrete_distributionを使ったときのおみくじプログラム
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> | |
int main() | |
{ | |
std::vector<int> prob = {1, 9, 25, 25, 30, 9, 1}; | |
const std::string str[] = {"大吉", "中吉", "小吉", "吉末", "吉", "凶", "大凶"}; | |
std::mt19937 rng; | |
std::discrete_distribution<int> dst(prob.begin(), prob.end()); | |
//おみくじを引きまくる | |
while(1) | |
{ | |
std::cout << str[dst(rng)] << std::endl; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment