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. LeetCode——Decode String

    Question Given an encoded string, return it's decoded string. The encoding rule is: k[encoded_string ...

  2. rsync | scp文件同步命令使用

    现在有一台服务器A,目录/data2/abc下存在若干文件夹和文件,需要复制到服务器B中.这时,可以在服务器A上执行rsync或者scp命令,将文件夹或文件复制到服务器B中. SCP: scp /da ...

  3. POJ2159 ancient cipher - 思维题

    2017-08-31 20:11:39 writer:pprp 一开始说好这个是个水题,就按照水题的想法来看,唉~ 最后还是懵逼了,感觉太复杂了,一开始想要排序两串字符,然后移动之类的,但是看了看 好 ...

  4. Python性能(转)

    第一部分 阅读 Zen of Python,在Python解析器中输入 import this. 一个犀利的Python新手可能会注意到"解析"一词, 认为Python不过是另一门 ...

  5. harbor 管理Helm Chart包

    官方网站:https://github.com/goharbor/harbor官方用户手册:https://github.com/goharbor/harbor/blob/master/docs/us ...

  6. Yii框架(一)

    这里接触了 MVC 设计模式中的控制器和视图部分. 创建了一个操作作为控制器的一部分去处理特定请求. 然后又创建了一个视图去构造响应内容. 在这个小例子中,没有模型调用,唯一涉及到数据的地方是 mes ...

  7. PHP数据库链接类(PDO+Access)

    PHP PDO Access链接 class DbHelpClass { private $conn; private $qxId; private $ret; function __construc ...

  8. angularjs1 自定义图片查看器(可旋转、放大、缩小、拖拽)

    笔记: angularjs1 制作自定义图片查看器(可旋转.放大.缩小.拖拽) 2018-01-12 更新  可以在我的博客  查看我 已经封装好的 纯 js写的图片查看器插件    博客链接 懒得把 ...

  9. python ssh登录

    3. 编写linkssh.py #!/usr/bin/env python# -*- coding: utf-8 -*-# filename: pexpect_test.py'''Created on ...

  10. Quartz教程二:API,Job和Trigger

    原文链接 | 译文链接 | 翻译:nkcoder | 校对:方腾飞 本系列教程由quartz-2.2.x官方文档翻译.整理而来,希望给同样对quartz感兴趣的朋友一些参考和帮助,有任何不当或错误之处 ...