Laitofai

13

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