package main import ( "flag" "fmt" ) const ( szie int = 5 ) var p *int = flag.Int("p", 0, "ente page") var s *int = flag.Int("s", 10, "ente szie") func main() { flag.Parse() data := make([]int, *s) for i := 1; i < *s; i++ { data[i] = i } newd := make([]int, szie) if *p <= 0 { newd = data[:szie] } else { m := *p * szie if m <= *s { j := m - szie newd = data[j:m] } } fmt.Printf("%v", newd) }
有疑问加站长微信联系(非本文作者)