Laitofai

13

May 12th, 2019
159
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.55 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3.  
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     int arr[26] = {0};
  9.     int mxIndex = 0;
  10.     string str;
  11.     getline(cin, str);
  12.     for(int i = 0; i < str.length(); i++){
  13.         if(str[i] == '.'){
  14.             break;
  15.         }
  16.         if(isalpha(str[i])){
  17.             int index = tolower(str[i]) - 97;
  18.             arr[index]++;
  19.             if(arr[index] > arr[mxIndex]){
  20.                 mxIndex = index;
  21.             }
  22.         }
  23.     }
  24.     cout << (char)(mxIndex + 97) << " " << arr[mxIndex];
  25.     return 0;
  26. }
Advertisement
Add Comment
Please, Sign In to add comment