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 二.模型评价 模型训练好后,度量模型拟合效果的 ...
随机推荐
- js去除前后空格
<script language="javascript"> String.prototype.trim=function(){ return this.rep ...
- maven下载与配置环境变量
1.打开maven官网下载 http://maven.apache.org/download.cgi 下载 解压(这里博主放在D盘下) 2.配置环境变量 验证是否配置成功 3.本地仓库配置
- 自学Java测试代码二String, StringBuffer
2017-08-23 10:38:01 writer:pprp package test; import java.util.*; public class test2 { public static ...
- Mysql建表好的例子
1. DROP TABLE IF EXISTS `sys_warehouse_area`;CREATE TABLE `sys_warehouse_area` ( `id` bigint(20) NOT ...
- 【三小时学会Kubernetes!(三) 】Service实践
服务Service Kubernetes 服务资源可以作为一组提供相同服务的 Pod 的入口.这个资源肩负发现服务和平衡 Pod 之间负荷的重任,如图 16 所示. 图16:Kubernetes 服务 ...
- maven 引入jar包
问题描述:自己的项目需要引入jar包,已知jar包名字,怎么在maven中添加依赖,使其能自动导入? 第一次使用:本文作为记录! 首先,找到maven仓库的网址!如下: http://mvnrepos ...
- 编码转换 Native / UTF-8 / Unicode
Native/Unicode Native 这是一个例子,this is a example Unicode 这是一个例子,this is a example Native/UTF-8 Nativ ...
- IOS-相机、相册
// // ViewController.m // IOS_0301_相册和相机 // // Created by ma c on 16/3/1. // Copyright © 2016年 博文科技. ...
- VS2010制作安装程序
转自(http://blog.csdn.net/wenmang1977/article/details/7733685) 序 前些天想写一下制作安装程序,由于要写的内容比较多,一拖再拖,不过坚持就是胜 ...
- java程序设计基础篇 复习笔记 第一单元
java语言程序设计基础篇笔记1. 几种有名的语言COBOL:商业应用FORTRAN:数学运算BASIC:易学易用Visual Basic,Delphi:图形用户界面C:汇编语言的强大功能和易学性,可 ...