c++11 随机代码记录

复制代码
// 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;
}
复制代码

记录

posted on   itdef  阅读(323)  评论(0编辑  收藏  举报

努力加载评论中...

导航

< 2025年3月 >
23 24 25 26 27 28 1
2 3 4 5 6 7 8
9 10 11 12 13 14 15
16 17 18 19 20 21 22
23 24 25 26 27 28 29
30 31 1 2 3 4 5

统计

点击右上角即可分享
微信分享提示