learn go random
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的更多相关文章
- Growing Pains for Deep Learning
Growing Pains for Deep Learning Advances in theory and computer hardware have allowed neural network ...
- 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 ...
- Learn day6 模块pickle\json\random\os\zipfile\面对对象(类的封装 操作 __init__)
1.模块 1.1 pickle模块 # ### pickle 序列化模块 import pickle """ 序列化: 把不能够直接存储的数据变得可存储 反序列化: 把数 ...
- 提高神经网络的学习方式Improving the way neural networks learn
When a golf player is first learning to play golf, they usually spend most of their time developing ...
- Beginners Guide To Learn Dimension Reduction Techniques
Beginners Guide To Learn Dimension Reduction Techniques Introduction Brevity is the soul of wit This ...
- Learn Docker
Learn Docker A Container is to VM today, what VM was to Physical Servers a while ago. The workload s ...
- cf472A Design Tutorial: Learn from Math
A. Design Tutorial: Learn from Math time limit per test 1 second memory limit per test 256 megabytes ...
- Bagging决策树:Random Forests
1. 前言 Random Forests (RF) 是由Breiman [1]提出的一类基于决策树CART的Bagging算法.论文 [5] 在121数据集上比较了179个分类器,效果最好的是RF,准 ...
- (原创)(三)机器学习笔记之Scikit Learn的线性回归模型初探
一.Scikit Learn中使用estimator三部曲 1. 构造estimator 2. 训练模型:fit 3. 利用模型进行预测:predict 二.模型评价 模型训练好后,度量模型拟合效果的 ...
随机推荐
- ”由于没有远程桌面授权服务器可以提供许可证,远程会话被中断“的解决方案
由于windows server 2012 R2 Datacenter 安装了 远程桌面角色,但是这个角色是120天免费的,需要购买授权的. 解决方案: 删除这个角色,就可以正常进行远程桌面连接了.但 ...
- JDBC 插入大批量数据
时不时会有大量数据的插入操作,方式有多种,效率不同: 1. statement 2. prepareStatement 3. statement/prepareStatement + batch 4. ...
- java工具类使用
ResourceBundle bundle = ResourceBundle.getBundle("res", new Locale("zh", "C ...
- 使用ssm整合是项目启动tomcat报错java.lang.IndexOutOfBoundsException
解决办法:删除.m2文件夹下的全部仓库,然后重启myeclipse,对项目进行maven project.问题解决. 在没有这样做时,除了tomcat启动会失败,项目还有会报如下错误: ①cvc-co ...
- jquery中的工具方法$.isFunction, $.isArray(), $.isWindow()
本文正式地址:http://www.xiabingbao.com/jquery/2015/07/25/jquery-judge-type 在javascript中对变量类型的判断中,我们讲解了了jqu ...
- python:用setup.py安装第三方包packages
python:用setup.py安装第三方包packages 原创 2016年12月10日 15:17:56 标签: python 8531 这次来介绍下python第三方包的安装,前面介绍了3种方式 ...
- [转]基于Visual Studio 2010 进行敏捷/Scrum模式开发
http://www.infoq.com/cn/articles/visual-studio-2010-agile-scrum-development 根据Forrester Research今年第二 ...
- 安装fcitx
设置好软件源后,终端执行: sudo apt-get install fcitx fcitx-ui-* fcitx-sunpinyin fcitx-googlepinyin fcitx-pinyin ...
- IOS-项目中常见文件介绍
一.项目文件结构示意图 二.文件介绍 1.products文件夹:主要用于mac电脑开发的可执行文件,ios开发用不到这个文件 2.frameworks文件夹主要用来放依赖的框架 3.test文件夹是 ...
- Ansible 小手册系列 十九(常见指令表)
Play 指令 说明 accelerate 开启加速模式 accelerate_ipv6 是否开启ipv6 accelerate_port 加速模式的端口 always_run any_error ...