mirror of
https://github.com/unknwon/the-way-to-go_ZH_CN.git
synced 2025-08-12 03:06:41 +08:00
fix start with or end with space,word count error
This commit is contained in:
@@ -32,6 +32,6 @@ func main() {
|
|||||||
func Counters(input string) {
|
func Counters(input string) {
|
||||||
nrchars += len(input) - 2 // -2 for \r\n
|
nrchars += len(input) - 2 // -2 for \r\n
|
||||||
// count number of spaces, nr of words is +1
|
// count number of spaces, nr of words is +1
|
||||||
nrwords += strings.Count(input, " ") + 1
|
nrwords += len(strings.Split(strings.Trim(input, " \n")," "))
|
||||||
nrlines++
|
nrlines++
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user