Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- int main() {
- int count = 0;
- char c;
- std::string str;
- while (std::getline(std::cin, str)) {
- for (auto iter = str.begin(); iter < str.end(); ++iter) {
- c = *iter;
- if ((*iter & 240) == 240) { //1111 0000
- ++iter;
- ++iter;
- ++iter;
- ++count;
- } else if ((*iter & 240) == 224) { //1110 0000
- ++iter;
- ++iter;
- ++count;
- } else if ((*iter & 240) == 192 || (*iter & 240) == 208) { //1100 0000 или 1101 0000
- ++iter;
- ++count;
- } else {
- ++count;
- }
- }
- }
- std::cout << count;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement