【牛客刷题】HJ13 句子逆序
题目本身不难,但是牛客的输入样例很坑,因此只好使用bufio来进行输入了:
package main
import (
"bufio"
"fmt"
"os"
"strings"
)
func main() {
input := bufio.NewScanner(os.Stdin)
input.Scan()
s := input.Text()
strs := strings.Fields(s)
var arr []string
for _, v := range strs {
arr = append(arr, v)
}
for i, j := 0, len(strs)-1; i < j; i, j = i+1, j-1 {
strs[i], strs[j] = strs[j], strs[i]
}
for _, v := range strs {
fmt.Printf("%s ", v)
}
}