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 二.模型评价 模型训练好后,度量模型拟合效果的 ...
随机推荐
- linux 搭建Java环境
一.下载jdk/jre文件 下载链接 二.安装Java环境 1.解压文件到 /usr/java 目录 # tar zxvf jre-8u60-linux-x64.gz 2.配置环境变量 ...
- Xampp mysql启动
因为最近项目要用到php,需要集成Xampp环境,但是并没有接触过php,从官网下载了Xampp后,基本上就是傻瓜式安装了, 完成安装界面如下: 点击Apache的start可以正常启动,点击MYSQ ...
- eclipse中把多个项目放在一个文件夹里
1..Package Explorer 可以在这里打开 2.选择Working sets 3.新建java working set 4.把文件夹显示出来 5.可以把项目移动到文件夹里面了,鼠标左键拖就 ...
- C#(Wpf)实现小键盘
花了一天时间小键盘基本功能已完成,先看看效果图吧! 默认: Shift: Caps Lock: Button style <Style x:Key="KeyButton" T ...
- RocketMQ 自己的整理和理解
每个人的想法不同, RocketMQ 介绍的时候就说 是阿里从他们使用的上 解耦出来 近一步简化 便捷的 目的当然是 让其能快速入手和开发 如果不是在项目设计层面上 只是使用的话 从Git上下载该项目 ...
- Android开发-网络通信1
使用 org.apache.http.client.HttpClient; 一开始从官网下载HttpClient 4.5:http://hc.apache.org/downloads.cgi ,解压之 ...
- jmeter-对响应数据进行unicode转码
1,请求接口成功后,返回数据为unicode编码,查看不方便
- LNMP的搭建与原理
常见的web框架结构:例如:lnmp和:ampL=LINUX N=NGINX A=APACHE P=php T=Tomcat lnmp的原理 在LNMP组合工作时,首先是用户通过浏览器输入域名请求Ng ...
- hdu4453
题解: splay模板 删除,翻转等等 代码: #include<cstdio> #include<cstring> #include<cmath> #includ ...
- 如何解决svn Authorization failed错误
出现这种问题肯定是SVN服务器出现了问题,需要修改其三个配置文件: 1.svnserve.conf: [general] anon-access = read auth-access = write ...