fork download
  1. #include <iostream>
  2. #include <vector>
  3. #include <queue>
  4. #include <iterator>
  5. #include <ostream>
  6.  
  7. template<typename T>
  8. std::ostream &operator <<(std::ostream &os, const std::vector<T> &v) {
  9. using namespace std;
  10. copy(v.begin(), v.end(), std::ostream_iterator<T>(os, "\n"));
  11. return os;
  12. }
  13.  
  14. // Заполняем вектор частот символов
  15. // Сохраняем все символы алфавита в std::set
  16. void get_data(std::vector< double > &alpha){
  17. char c;
  18. double freq;
  19.  
  20. int overall = 0;
  21. while(std::cin >> c){
  22. alpha[c] += 1;
  23. ++overall;
  24. }
  25. for(auto& it : alpha) {
  26. it = it / double(overall);
  27. }
  28. }
  29.  
  30.  
  31. int main(){
  32. std::vector< double > alpha(255, 0.0);
  33.  
  34. get_data(alpha);
  35.  
  36. std::cout << alpha;
  37.  
  38. }
Success #stdin #stdout 0s 3460KB
stdin
dasdsafsadfasdfasfd
stdout
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.263158
0
0
0.263158
0
0.210526
0
0
0
0
0
0
0
0
0
0
0
0
0.263158
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0