package main
import (
"bufio"
"fmt"
"os"
"strconv"
"strings"
"time"
)
func main() {
num_song := make(map[int64]string)
num_song[1] = "1像铅笔能写字"
num_song[2] = "2像鸭子水中游"
num_song[3] = "3像耳朵能听话"
num_song[4] = "4像红旗迎风飘"
num_song[5] = "5像鱼钩把鱼钓"
num_song[6] = "6像哨子能吹响"
num_song[7] = "7像镰刀能割草"
num_song[8] = "8像葫芦上下圆"
num_song[9] = "9像勺子能盛饭"
scaner := bufio.NewReader(os.Stdin)
for true {
input, err := scaner.ReadString('\n')
if err != nil {
panic(fmt.Errorf("发生致命错误: %w \n", err))
}
inputNum := strings.Split(input, "\n")[0]
//TODO 下面我们就可以根据text输入的内容进行调用不同的函数了。
fmt.Println("哦哦说:", inputNum)
if inputNum == "" {
time.Sleep(3 * time.Second)
println("inputNum:", inputNum)
} else {
if num, err := strconv.ParseInt(inputNum, 10, 0); err != nil {
println(err.Error())
} else {
println("童童说: ", num_song[num])
}
}
}
}
【kids progromming】数字1-9
于 2023-02-28 20:26:03 首次发布