package main
import (
"fmt"
"strings"
)
func countWords(input string) int {
// Split the string by whitespace
words := strings.Fields(input)
return len(words)
}
func main() {
var string1, string2 string
string1 = "c c++ pascal java c#";
string2 = "go rust php javascript swift";
// Count words in both strings
words1 := countWords(string1)
words2 := countWords(string2)
// Compare word counts
if words1 == words2 {
fmt.Println("Both strings have the same number of words.")
} else {
fmt.Println("The strings have a different number of words.")
}
}
/*
run:
Both strings have the same number of words.
*/