package main

 // 参考文档:
// go 基本类型和运算符
// https://github.com/Unknwon/the-way-to-go_ZH_CN/blob/master/eBook/04.5.md // 引入需要使用的类
import (
"fmt" // 格式化输出
"math/rand" // 数学随机数
"time" // 时间
) func main () {
// 获取整形随机数
for i := ; i < ; i++ {
a := rand.Int()
fmt.Printf("%d / ", a)
}
fmt.Println() // 函数 rand.Intn 返回介于 [0, n) 之间的伪随机数。
for i := ; i < ; i++ {
r := rand.Intn()
fmt.Printf("%d / ", r)
}
fmt.Println() // 使用 Seed(value) 函数来提供伪随机数的生成种子,一般情况下都会使用当前时间的纳秒级数字
timens := int64(time.Now().Nanosecond())
rand.Seed(timens)
for i := ; i < ; i++ {
// 函数 rand.Float32 和 rand.Float64 返回介于 [0.0, 1.0) 之间的伪随机数,其中包括 0.0 但不包括 1.0。
fmt.Printf("%2.2f /", *rand.Float32())
}
fmt.Println()
}

learn go random的更多相关文章

  1. Growing Pains for Deep Learning

    Growing Pains for Deep Learning Advances in theory and computer hardware have allowed neural network ...

  2. Curiosity-Driven Learning through Next State Prediction

    Curiosity-Driven Learning through Next State Prediction 2019-10-19 20:43:17 This paper is from: http ...

  3. Learn day6 模块pickle\json\random\os\zipfile\面对对象(类的封装 操作 __init__)

    1.模块 1.1 pickle模块 # ### pickle 序列化模块 import pickle """ 序列化: 把不能够直接存储的数据变得可存储 反序列化: 把数 ...

  4. 提高神经网络的学习方式Improving the way neural networks learn

    When a golf player is first learning to play golf, they usually spend most of their time developing ...

  5. Beginners Guide To Learn Dimension Reduction Techniques

    Beginners Guide To Learn Dimension Reduction Techniques Introduction Brevity is the soul of wit This ...

  6. Learn Docker

    Learn Docker A Container is to VM today, what VM was to Physical Servers a while ago. The workload s ...

  7. cf472A Design Tutorial: Learn from Math

    A. Design Tutorial: Learn from Math time limit per test 1 second memory limit per test 256 megabytes ...

  8. Bagging决策树:Random Forests

    1. 前言 Random Forests (RF) 是由Breiman [1]提出的一类基于决策树CART的Bagging算法.论文 [5] 在121数据集上比较了179个分类器,效果最好的是RF,准 ...

  9. (原创)(三)机器学习笔记之Scikit Learn的线性回归模型初探

    一.Scikit Learn中使用estimator三部曲 1. 构造estimator 2. 训练模型:fit 3. 利用模型进行预测:predict 二.模型评价 模型训练好后,度量模型拟合效果的 ...

随机推荐

  1. centos7更改主机名

    操作环境 [root@centos701 ~]# uname Linux [root@centos701 ~]# uname -a Linux centos701 3.10.0-693.el7.x86 ...

  2. Spring Boot 中yml配置文件

    步骤一:yml格式 现在大家发现,在springboot里还是要用到配置文件的. 除了使用.properties外,springboot还支持 yml格式. 个人觉得yml格式的可读性和..prope ...

  3. 解题报告:51nod 加农炮

    2017-10-07 16:15:16 writer:pprp 题目来源: Codility 基准时间限制:1 秒 空间限制:131072 KB 分值: 40 难度:4级算法题   一个长度为M的正整 ...

  4. 秒懂算法2——选择排序(C#实现)

    算法思路: 每趟走访元素揪出一个最小(或最大)的元素,和相应位置的元素交换.(用数组{6,9,13,2,4,64} 举例) {},{6 9 13 [2] 4 64}     //第一趟,揪出2 {2} ...

  5. springboot Actuator健康检查

    通过情况下,如我们想在系统中添加一个健康检查的接口,我们怎么做呢? 我们会新建一个类,或在已存在类的基础上添加检测接口. package com.crhms.medicareopinion; impo ...

  6. Javascript知识点汇总-初级篇

    JavaScript的数据类型都有什么? 基本数据类型:String,Boolean,Number,Undefined, Null 引用数据类型:Object(Array,Date,RegExp,Fu ...

  7. Ubuntu16.04 安装openssl

    1 下载 https://www.openssl.org/source/ 2 解压 3 安装 # ./config --prefix=/usr/local --openssldir=/usr/loca ...

  8. vs2012 在调试或运行的过程中不能加断点

    在使用VS2012 的过程中,突然发现在调试的过程中,不能加断点,显示断点未能绑定.在搜寻了很多解决方案后未能解决,3.23这一天,重装了VS也没有用. 便想着把网上所有的方法都试个遍也要解决这个问题 ...

  9. centos网卡配置

    DEVICE=物理设备名 IPADDR=IP地址 NETMASK=掩码值 NETWORK=网络地址 BROADCAST=广播地址 GATEWAY=网关地址 TYPE=Ethernet (网络类型)ON ...

  10. Lua学习笔记1,基本数据类型

    1.字符串的连接使用的是  .. ,如 print(123 .. 44) 输出 12344 print ('a' .. 'b') 输出 ab print(123 .. 44)这句的时候 .. 两边要空 ...