码迷,mamicode.com
首页 > 编程语言 > 详细

c++11 随机代码记录

时间:2015-11-28 13:31:17      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:

// RadomTest.cpp : 定义控制台应用程序的入口点。
//

#include "stdafx.h"
#include <iostream>
#include <random>
#include <time.h>

using namespace std;

int main()
{

        std::default_random_engine random(time(NULL));
        std::uniform_int_distribution<int> dis1(0, 100);
    

        for (int i = 0; i < 10; ++i)
            cout << dis1(random) << endl;
        cout << endl;
        //==========================================
        std::random_device rd;

        std::default_random_engine e(rd());

        std::uniform_int_distribution <> u(0, 100);

        for (size_t i = 0; i < 10; i++) {

            cout << u(e) << endl;

        }
    
    
    return 0;
}

记录

c++11 随机代码记录

标签:

原文地址:http://www.cnblogs.com/itdef/p/5002460.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!