第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號(hào)安全,請(qǐng)及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會(huì)有你想問的

在自定義范圍內(nèi)生成隨機(jī)數(shù)

在自定義范圍內(nèi)生成隨機(jī)數(shù)

Go
SMILET 2023-04-17 16:33:10
我有一個(gè)從“l(fā)ocalhost:8080/1”開始的腳本,有一個(gè) 上一個(gè)和下一個(gè)鏈接我需要添加帶有自定義范圍的隨機(jī)鏈接,我可以像這樣更改:小數(shù)字,如 100 到 200 "localhost:8080/100 - 200" 和甚至像這樣的大數(shù)字:“16567684686592643791596485465456223131545455682945955”所以:// Get next and previous page numbersprevious := new(big.Int).Sub(page, one)next := new(big.Int).Add(page, one)random :=????
查看完整描述

1 回答

?
心有法竹

TA貢獻(xiàn)1866條經(jīng)驗(yàn) 獲得超5個(gè)贊

您需要使用 package?crypto.randInt()函數(shù),它確實(shí)支持big.Int(而不是math.randpackage)

package main


import (

? ? "fmt"

? ? "math/big"

? ? "crypto/rand"

)


func main() {

? ? var prime1, _ = new(big.Int).SetString("21888242871839275222246405745257275088548364400416034343698204186575808495617", 10)

? ? // Generate random numbers in range [0..prime1]

? ? // Ignore error values

? ? // Don't use this code to generate secret keys that protect important stuff!

? ? x, _ := rand.Int(rand.Reader, prime1)

? ? y, _ := rand.Int(rand.Reader, prime1)

? ? fmt.Printf("x: %v\n", x)

? ? fmt.Printf("y: %v\n", y)


}


查看完整回答
反對(duì) 回復(fù) 2023-04-17
  • 1 回答
  • 0 關(guān)注
  • 138 瀏覽
慕課專欄
更多

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購(gòu)課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動(dòng)學(xué)習(xí)伙伴

公眾號(hào)

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號(hào)