题解 | 明明的随机数
package main import ( "fmt" "sort" ) func main() { var n int fmt.Scan(&n) checkMap := map[int]bool{} targetArr := []int{} for i := 0; i < n; i++ { var v int fmt.Scan(&v) if _, ok := checkMap[v]; ok { continue } checkMap[v] = true targetArr = append(targetArr, v) } sort.Ints(targetArr) for _, v := range targetArr { fmt.Printf("%v\n", v) } }