fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. #include <set>
  5.  
  6. // Заполняем вектор частот символов
  7. // Сохраняем все символы алфавита в std::set
  8. void get_data(std::set< std::pair<char, double> > &alpha){
  9. std::vector<char> fr(256);
  10. char c;
  11. double freq;
  12.  
  13. while(std::cin >> c){
  14. fr[c]++; // Вектор хранит количество символов с кодом c
  15. alpha.insert(std::make_pair(c, -1));
  16. }
  17. for(auto it = alpha.begin(); it != alpha.end(); it++)
  18. (*it).second = fr[(*it).first] / alpha.size();
  19. }
  20.  
  21. void Huffman(std::set<char> &alpha, std::vector<double> &freq){
  22.  
  23. }
  24.  
  25. int main(){
  26. std::vector<double> freq;
  27. std::set<char> alpha;
  28.  
  29.  
  30.  
  31. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
bgbdgbdndndnd
compilation info
prog.cpp: In function 'void get_data(std::set<std::pair<char, double> >&)':
prog.cpp:18:16: error: assignment of member 'std::pair<char, double>::second' in read-only object
   (*it).second = fr[(*it).first] / alpha.size();
                ^
stdout
Standard output is empty