Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- using namespace std;
- int main()
- {
- int arr[26] = {0};
- int mxIndex = 0;
- string str;
- getline(cin, str);
- for(int i = 0; i < str.length(); i++){
- if(str[i] == '.'){
- break;
- }
- if(isalpha(str[i])){
- int index = tolower(str[i]) - 97;
- arr[index]++;
- if(arr[index] > arr[mxIndex]){
- mxIndex = index;
- }
- }
- }
- cout << (char)(mxIndex + 97) << " " << arr[mxIndex];
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment