Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <vector>
- #include <string>
- #include <algorithm>
- #include <queue>
- #include <map>
- using namespace std;
- int main()
- {
- #ifdef _DEBUG
- freopen("input.txt","r",stdin);
- freopen("output.txt","w",stdout);
- #endif
- string str = "abcdefghijklmnopqrstuvwxwzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- vector <string> a;
- map <unsigned char, float> m;
- while (cin)
- {
- string s;
- getline(cin, s);
- if (s != "")
- {
- a.push_back(s);
- }
- }
- for (int i = 0; i < a.size(); ++i)
- {
- for (int j = 0; j < a[i].length(); ++j)
- {
- if (isalpha(a[i][j]))
- {
- if (m.find(a[i][j]) == m.end())
- m.insert(make_pair(a[i][j], 1));
- else
- m.find(a[i][j])->second++;
- }
- }
- }
- for (auto it = m.begin(); it != m.end(); ++it)
- {
- for (int i = 0; i < str.length(); ++i)
- {
- if (m.find(str[i]) == m.end())
- m.insert(make_pair(str[i], 0));
- }
- }
- int n = 0;
- for (int i = 0; i < a.size(); ++i)
- n += a[i].length();
- for (auto it = m.begin(); it != m.end(); ++it)
- {
- cout << it->first << ": ";
- printf("%.3f",it->second/n);
- cout << endl;
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement