This is a creation in Article, where the information may have evolved or changed.
Randomly generate a number, enter a number to see if the pair, matching the junction speed, the opposite hint is big or small,
The code is as follows: Package main
Import ("Bufio" "FMT" "Math/rand" "OS" "StrConv" "Time")var(Endnumint //Set the range of build numbers)func main(){i: = Createrandomnumber (Endnum)//fmt. Println ("generates integers within a specified range:", I)//This sentence is used for debuggingFmt. Println ("Please enter an integer, Range: 0-", endnum) Flag: =trueReader: = Bufio. Newreader (OS. Stdin) forFlag {Data, _, _: = Reader. ReadLine () command, err: = StrConv. Atoi (string(data))//string to int, and make the input format judgment ifErr! = Nil {fmt. Println ("format is incorrect, please enter a number") }Else{FMT. Println ("The number you entered:", command)ifCommand = = I {flag =falseFmt. Println ("Congratulations, you're right.") }Else ifCommand < I {FMT. Println ("The number you entered is less than the number generated, don't lose heart!" One more time. ") }Else ifCommand > I {FMT. Println ("The number you entered is greater than the number generated, don't lose heart!" One more time. ") } } }}func init(){Endnum =Ten}//generate integers within a specified range//Set starting digital range, 0 start, endnum cutofffunc createrandomnumber(endnum int) int {r: = rand. New (Rand. Newsource (time. Now (). Unixnano ()))returnR.INTN (Endnum)}