Advertisement
vardgrig

tarer

Dec 1st, 2021
739
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.72 KB | None | 0 0
  1. #include <map>
  2. #include <iostream>
  3. using namespace std;
  4.  
  5. int main() {
  6.     std::string word = "This is the ultimate C++ advice that Lord Hakobyan and Graf Mher will give you. Just remember a simple thing: “using namespace std;” bad. This advice should be followed throughout this entire module, otherwise we will be sad.";
  7.  
  8.     std::map<char, int> charCount;
  9.     for (unsigned int i = 0; i < word.size(); i += 1) {
  10.         if(word[i] != ' ')
  11.             charCount[word[i]] += 1;
  12.     }
  13.  
  14.     for (std::map<char, int>::iterator it = charCount.begin(); it != charCount.end(); it++) {
  15.         if (it->second >= 10) {
  16.             std::cout << it->first << ": " << it->second << std::endl;
  17.         }
  18.     }
  19.  
  20.     return 0;
  21. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement