Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <sstream>
- #include <fstream>
- #include <string>
- #include <iomanip>
- #include <vector>
- #include <string>
- using namespace std;
- //size_t wc(istream &read_stream)
- //{
- // string word;
- // size_t cnt = 0;
- //
- // while( read_stream >> word )
- // {
- // cnt++;
- // }
- //
- // return cnt;
- //}
- //// program zlicza libcze a w ca³ym tekscie i daje do characters[0]
- void count_characters(istream &read_stream, size_t characters[26])
- {
- size_t u = 0;
- char y;
- while(read_stream.get(y))
- {
- y = tolower(y);
- // range
- if(y >= 'a' && y<='z')
- {
- characters[y-'a']++;
- }
- }
- for (int i = 0; i<26;i++)
- {cout<<characters[i]<<endl;}
- }
- //// for a=2087 i print *** to MAX
- //void print_histogram (std::size_t &characters[26], const int MAX)
- //{
- //
- //}
- int main()
- {
- size_t characters[26];
- ifstream read_stream("texts/hamlet.txt");
- // if (!read_stream.is_open())
- // {
- // std::cout << "File was not opened!"<<std::endl;
- // }
- // std::cout << wc(read_stream)<< std::endl;
- count_characters(read_stream,characters);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement