mirror of
https://github.com/krahets/hello-algo.git
synced 2025-11-02 04:31:55 +08:00
Add build script for Go and update Go codes.
This commit is contained in:
@ -5,7 +5,6 @@
|
||||
package chapter_computational_complexity
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"math/rand"
|
||||
)
|
||||
|
||||
@ -34,14 +33,3 @@ func findOne(nums []int) int {
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
/* Driver Code */
|
||||
func main() {
|
||||
for i := 0; i < 10; i++ {
|
||||
n := 100
|
||||
nums := randomNumbers(n)
|
||||
index := findOne(nums)
|
||||
fmt.Println("\n数组 [ 1, 2, ..., n ] 被打乱后 =", nums)
|
||||
fmt.Println("数字 1 的索引为", index)
|
||||
}
|
||||
}
|
||||
|
||||
@ -14,7 +14,7 @@ func TestWorstBestTimeComplexity(t *testing.T) {
|
||||
n := 100
|
||||
nums := randomNumbers(n)
|
||||
index := findOne(nums)
|
||||
fmt.Println("打乱后的数组为", nums)
|
||||
fmt.Println("\n数组 [ 1, 2, ..., n ] 被打乱后 =", nums)
|
||||
fmt.Println("数字 1 的索引为", index)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user