题解 | #明明的随机数#
明明的随机数
https://www.nowcoder.com/practice/3245215fffb84b7b81285493eae92ff0
package main import ( "fmt" "bufio" "os" "strconv" "sort" ) func main() { //采用map是为了去重(主要是自己懒,具体消耗没有考虑) inputNumber := make(map[int]string) sc := bufio.NewScanner(os.Stdin) sc.Scan() //第一个整数不要了 for sc.Scan() { temp, err := strconv.Atoi(sc.Text()) if err != nil { fmt.Println("strconv atoi err= ", err) } inputNumber[temp] = "" } //fmt.Println(inputNumber) var intArray []int for k, _ := range inputNumber { intArray = append(intArray, k) } sort.Ints(intArray) for _, v := range intArray { fmt.Println(v) } }