fork(1) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. #include <set>
  5.  
  6. // Заполняем вектор частот символов
  7. // Сохраняем все символы алфавита в std::set
  8. void get_data(std::vector< 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. // Добавить новую пару в том случае, если символа c нет в векторе
  16. alpha.push_back(std::make_pair(c, -1));
  17. }
  18. for(std::vector< std::pair<char, double> >::iterator it = alpha.begin(); it != alpha.end(); it++)
  19. (*it).second = fr[(*it).first] / alpha.size();
  20. }
  21.  
  22. void Huffman(std::set<char> &alpha, std::vector<double> &freq){
  23.  
  24. }
  25.  
  26. int main(){
  27. std::vector< std::pair<char, double> > alpha;
  28.  
  29. get_data(alpha);
  30.  
  31. for(auto it = alpha.begin(); it != alpha.end(); it++)
  32. std::cout < (*it) << " ";
  33. }
Compilation error #stdin compilation error #stdout 0s 3464KB
stdin
ggbhdghdshdbdghdhdgf
compilation info
prog.cpp: In function 'int main()':
prog.cpp:32:21: error: no match for 'operator<<' (operand types are 'std::pair<char, double>' and 'const char [2]')
   std::cout < (*it) << " ";
                     ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:628:5: note: candidate: template<class _CharT, class _Traits, class _Tp> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&&, const _Tp&)
     operator<<(basic_ostream<_CharT, _Traits>&& __os, const _Tp& __x)
     ^
/usr/include/c++/5/ostream:628:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:574:5: note: candidate: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const unsigned char*)
     operator<<(basic_ostream<char, _Traits>& __out, const unsigned char* __s)
     ^
/usr/include/c++/5/ostream:574:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<char, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:569:5: note: candidate: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const signed char*)
     operator<<(basic_ostream<char, _Traits>& __out, const signed char* __s)
     ^
/usr/include/c++/5/ostream:569:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<char, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:556:5: note: candidate: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, const char*)
     operator<<(basic_ostream<char, _Traits>& __out, const char* __s)
     ^
/usr/include/c++/5/ostream:556:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<char, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/ostream:638:0,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/ostream.tcc:321:5: note: candidate: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const char*)
     operator<<(basic_ostream<_CharT, _Traits>& __out, const char* __s)
     ^
/usr/include/c++/5/bits/ostream.tcc:321:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:539:5: note: candidate: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const _CharT*)
     operator<<(basic_ostream<_CharT, _Traits>& __out, const _CharT* __s)
     ^
/usr/include/c++/5/ostream:539:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:519:5: note: candidate: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, unsigned char)
     operator<<(basic_ostream<char, _Traits>& __out, unsigned char __c)
     ^
/usr/include/c++/5/ostream:519:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<char, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:514:5: note: candidate: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, signed char)
     operator<<(basic_ostream<char, _Traits>& __out, signed char __c)
     ^
/usr/include/c++/5/ostream:514:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<char, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:508:5: note: candidate: template<class _Traits> std::basic_ostream<char, _Traits>& std::operator<<(std::basic_ostream<char, _Traits>&, char)
     operator<<(basic_ostream<char, _Traits>& __out, char __c)
     ^
/usr/include/c++/5/ostream:508:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<char, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:502:5: note: candidate: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, char)
     operator<<(basic_ostream<_CharT, _Traits>& __out, char __c)
     ^
/usr/include/c++/5/ostream:502:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/iostream:39:0,
                 from prog.cpp:1:
/usr/include/c++/5/ostream:497:5: note: candidate: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, _CharT)
     operator<<(basic_ostream<_CharT, _Traits>& __out, _CharT __c)
     ^
/usr/include/c++/5/ostream:497:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/bits/ios_base.h:46:0,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/system_error:209:5: note: candidate: template<class _CharT, class _Traits> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::error_code&)
     operator<<(basic_ostream<_CharT, _Traits>& __os, const error_code& __e)
     ^
/usr/include/c++/5/system_error:209:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   std::cout < (*it) << " ";
                        ^
In file included from /usr/include/c++/5/string:52:0,
                 from /usr/include/c++/5/bits/locale_classes.h:40,
                 from /usr/include/c++/5/bits/ios_base.h:41,
                 from /usr/include/c++/5/ios:42,
                 from /usr/include/c++/5/ostream:38,
                 from /usr/include/c++/5/iostream:39,
                 from prog.cpp:1:
/usr/include/c++/5/bits/basic_string.h:5170:5: note: candidate: template<class _CharT, class _Traits, class _Alloc> std::basic_ostream<_CharT, _Traits>& std::operator<<(std::basic_ostream<_CharT, _Traits>&, const std::basic_string<_CharT, _Traits, _Alloc>&)
     operator<<(basic_ostream<_CharT, _Traits>& __os,
     ^
/usr/include/c++/5/bits/basic_string.h:5170:5: note:   template argument deduction/substitution failed:
prog.cpp:32:24: note:   'std::pair<char, double>' is not derived from 'std::basic_ostream<_CharT, _Traits>'
   std::cout < (*it) << " ";
                        ^
stdout
Standard output is empty