fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <cctype>
  4. using namespace std;
  5.  
  6. const int ALPHABET = 26;
  7.  
  8. int main() {
  9. string line;
  10. int frequency[ALPHABET] = {0};
  11. while (getline(cin, line)) {
  12. if (line.empty()) {
  13. break;
  14. }
  15. for (char ch : line) {
  16. if (isalpha(ch)) {
  17. ch = tolower(ch);
  18. ++frequency[ch - 'a'];
  19. }
  20. }
  21. }
  22. int maxFreq = 0;
  23. char maxChar = 'a';
  24. for (int i = 0; i < ALPHABET; ++i) {
  25. if (frequency[i] > maxFreq) {
  26. maxFreq = frequency[i];
  27. maxChar = i + 'a';
  28. }
  29. }
  30. if (maxFreq > 0) {
  31. cout << maxChar << endl;
  32. }
  33. return 0;
  34. }
  35.  
Success #stdin #stdout 0s 5284KB
stdin
SAlut, Am fost lA mAre
stdout
a