go n以内的奇数输出为数组
https://golang.cafe/blog/golang-int-to-string-conversion-example.html
strconv:integer转换为string
package main
import "fmt"
import "strconv"
//import "reflect"
func print_odd_number (number int) []string{
var n int
//var t []string
t := []string{}
for n=1; n<=number; n++{
if n%2==0{
//fmt.Println("结果没有余数:", n)
}else{
//fmt.Println(n)
//fmt.Println(n, reflect.TypeOf(n))
t = append(t, strconv.Itoa(n))
//fmt.Println(t, reflect.TypeOf(t))
}
}
return t
}
func main() {
fmt.Println(print_odd_number(10))
}go run test_odd.go
[1 3 5 7 9]