Go语言中文网 为您找到相关结果 4

golang 1-99打乱成随机组合

构成一个1-99的随机组合 // 生成1-100的数。然后随机打乱 func rd_num() { sou_num := make([]int, 100) i := 0 for k, _ := range sou_num { i++ sou_num[k] = i fmt.Printf("%d[%d] ", sou_num[k], k) } fmt.Println("\n-----") for j := 0; j < 100; j++ { if j == 99 { break } x := random(j, 99) sou_num[x], sou_num[j] = sou_num[j], sou_num[x] fmt.Printf("%d ", sou_num[j]) } fmt.Print...阅读全文

博文 2018-04-11 15:33:08 捍卫机密

Base64 GO加密简单用法 如何深入用法

**这样的简单用法觉得没什么意思 什么办法设计的复杂一点 当然可以改base64Table 的打乱顺序!还有什么办法没** ~~~ package main import ( "encoding/base64" "fmt" ) const ( base64Table = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/" ) var coder = base64.NewEncoding(base64Table) func base64Encode(src []byte) []byte { return []byte(coder.EncodeToString(src)) ...阅读全文

(初级)7.Shuffle an Array

打乱一个没有重复元素的数组。 image.png golang代码: package shuffle import ( "math/rand" "time" ) type Solution struct { array []int backup []int //备份 } func Constructor(nums []int) Solution { return Solution{ backup: append([]int{}, nums...), array: append([]int{}, nums...), } } // Reset the array to its original configuration and return it. func (this *Solution) ...阅读全文

博文 2018-08-11 16:35:19 one_zheng