Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- const int AlphSize = 52;
- int main()
- {
- string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
- int count[AlphSize] = { 0 };
- int iterations;
- string sentences;
- cin >> iterations;
- cin.get();
- for (int i = 0; i < iterations; i++) {
- getline(cin, sentences);
- for (int i = 0; i < sentences.size(); i++) {
- for (int j = 0; j < alphabet.size(); j++) {
- if (sentences[i] == alphabet[j]) {
- count[j] += 1;
- }
- }
- }
- }
- for (int i = 0; i < AlphSize; i++) {
- if (!(count[i] == 0)) {
- cout << alphabet[i] << ": " << count[i] << endl;
- }
- }
- cin.get();
- return 0;
- }
Add Comment
Please, Sign In to add comment