Guest User

Untitled

a guest
Jul 29th, 2016
643
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.68 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. const int AlphSize = 52;
  7.  
  8. int main()
  9. {
  10.     string alphabet = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ";
  11.     int count[AlphSize] = { 0 };
  12.     int iterations;
  13.     string sentences;
  14.     cin >> iterations;
  15.     cin.get();
  16.  
  17.     for (int i = 0; i < iterations; i++) {
  18.         getline(cin, sentences);
  19.         for (int i = 0; i < sentences.size(); i++) {
  20.             for (int j = 0; j < alphabet.size(); j++) {
  21.                 if (sentences[i] == alphabet[j]) {
  22.                     count[j] += 1;
  23.                 }
  24.             }
  25.         }
  26.     }
  27.  
  28.     for (int i = 0; i < AlphSize; i++) {
  29.         if (!(count[i] == 0)) {
  30.             cout << alphabet[i] << ": " << count[i] << endl;
  31.         }
  32.     }
  33.     cin.get();
  34.     return 0;
  35. }
Add Comment
Please, Sign In to add comment