Advertisement
FuFsQ

boring lection

Sep 24th, 2018
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.29 KB | None | 0 0
  1. #include <iostream>
  2. #include <vector>
  3. #include <map>
  4. #include <string>
  5.  
  6. using namespace std;
  7.  
  8. int main()
  9. {
  10.     std::string word;
  11.     std::getline(cin,word);
  12.  
  13.     int word_sz = word.size()-1;
  14.     vector<int> Mask;
  15.     vector<int> Counts;
  16.  
  17.     for(int i = word_sz; i > 0; i--){
  18.         Mask.push_back(i);
  19.         Counts.push_back(i+1);
  20.     }
  21.     Counts.emplace_back(1);
  22.  
  23.     int mask_sz = Mask.size();
  24.     int disp = 0;
  25.  
  26.     for(int i = 1; i < word_sz; i++)
  27.     {
  28.         int CTR = 0;
  29.         for(int k = disp; k < mask_sz; k++){
  30.             Counts[i+CTR] += Mask[k];
  31.             CTR++;
  32.         }
  33.  
  34.         disp++;
  35.     }
  36.     Counts[Counts.size()-1]++;
  37.  
  38.     map<char,int> Freq;
  39.  
  40.  
  41.  
  42.     for(register int i = 0; i < word_sz+1; i++)
  43.         Freq[word[i]] += Counts[i];
  44.  
  45.     for(auto &I : Freq)
  46.         cout << I.first << ": " << I.second << endl;
  47.  
  48.     /*std::string Buf;
  49.     for(auto K = Freq.cbegin(); K != Freq.cend(); K++){
  50.         Buf += (K->first + ": " + to_string(K->second) + '\n');
  51.     }*/
  52.  
  53.     /*string Dec = "";
  54.     int ctr = word_sz;
  55.     for(int x = 0; x < word_sz; x++)
  56.     {
  57.         for(int y = x; y < ctr; y++){
  58.             cout << Dec << word.substr(x,y) << " ::: X,Y = " << x << " " << y << endl;
  59.         }
  60.         Dec+=" ";
  61.     }*/
  62.  
  63.     return 0;
  64. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement