#include <iostream>
#include <string>
#include <sstream>
#include <clocale>
using namespace std;
int main() {
setlocale(LC_ALL, "");
string text;
cout << "Vvedite tekst: ";
getline(cin, text);
stringstream ss(text);
string word;
int count = 0;
cout << "\nSlova dlinoy 5 simvolov:" << endl;
while(ss >> word) {
// Подсчитываем количество символов (не байтов!)
int charCount = 0;
for(size_t i = 0; i < word.size(); ) {
if((word[i] & 0xC0) != 0x80) {
charCount++;
}
i++;
}
if(charCount == 5) {
cout << word << endl;
count++;
}
}
if(count == 0) {
cout << "Slova ne naydeny!" << endl;
} else {
cout << "\nNaydeno: " << count << endl;
}
return 0;
}