翻转单词顺序golang实现

func reverseWords(s string) string {
	tmp := strings.Fields(strings.Trim(s, " "))
	reverse(tmp)
	join := strings.Join(tmp, " ")
	return strings.Trim(join, "")
}
func reverse(s []string) []string {
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		s[i], s[j] = s[j], s[i]
	}
	return s
}
上一篇:说一说javascript跨域和jsonp


下一篇:JavaScript 跨域漫游