Advertisement
Guest User

Untitled

a guest
Dec 7th, 2016
63
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.79 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. int main() {
  5. int count = 0;
  6. char c;
  7. std::string str;
  8. while (std::getline(std::cin, str)) {
  9. for (auto iter = str.begin(); iter < str.end(); ++iter) {
  10. c = *iter;
  11. if ((*iter & 240) == 240) { //1111 0000
  12. ++iter;
  13. ++iter;
  14. ++iter;
  15. ++count;
  16. } else if ((*iter & 240) == 224) { //1110 0000
  17. ++iter;
  18. ++iter;
  19. ++count;
  20. } else if ((*iter & 240) == 192 || (*iter & 240) == 208) { //1100 0000 или 1101 0000
  21. ++iter;
  22. ++count;
  23. } else {
  24. ++count;
  25. }
  26. }
  27. }
  28. std::cout << count;
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement