#include <iostream>
#include <string>
#include <sstream>
int countWords(const std::string& line)
{
std::istringstream str(line);
std::string dump;
int count = 0;
while(str >> dump)
++count;
return count;
}
int main()
{
std::cout << "Enter line\n";
std::string line;
std::getline(std::cin, line);
std::cout << "Sentence: " << line << '\n' <<
"Word count: " << countWords(line) << '\n';
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8c3N0cmVhbT4KCmludCBjb3VudFdvcmRzKGNvbnN0IHN0ZDo6c3RyaW5nJiBsaW5lKQp7CiAgICBzdGQ6OmlzdHJpbmdzdHJlYW0gc3RyKGxpbmUpOwogICAgc3RkOjpzdHJpbmcgZHVtcDsKICAgIGludCBjb3VudCA9IDA7CiAgICB3aGlsZShzdHIgPj4gZHVtcCkKICAgICAgICArK2NvdW50OwogICAgcmV0dXJuIGNvdW50Owp9CgppbnQgbWFpbigpCnsKCXN0ZDo6Y291dCA8PCAiRW50ZXIgbGluZVxuIjsKICAgIHN0ZDo6c3RyaW5nIGxpbmU7CiAgICBzdGQ6OmdldGxpbmUoc3RkOjpjaW4sIGxpbmUpOwogICAgc3RkOjpjb3V0IDw8ICJTZW50ZW5jZTogIiA8PCBsaW5lIDw8ICdcbicgPDwKICAgICAgICAgICAgICAgICAiV29yZCBjb3VudDogIiA8PCBjb3VudFdvcmRzKGxpbmUpIDw8ICdcbic7Cn0K