题解 | #句子逆序#
句子逆序
http://www.nowcoder.com/practice/48b3cb4e3c694d9da5526e6255bb73c3
package main
import (
"fmt"
"io"
)
func main() {
var res []string
for {
var s string
_, err := fmt.Scan(&s)
if err == io.EOF {
break
}
res = append(res, s)
}
var i = len(res) - 1
fmt.Print(res[i])
i--
for ; i >= 0; i-- {
fmt.Print(" ", res[i])
}
fmt.Println()
}