fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <cctype>
  5. #include <array>
  6. using namespace std;
  7.  
  8.  
  9.  
  10.  
  11.  
  12.  
  13. int maxx(array<int,26> arr){
  14. int maximum = 0;
  15. for(int i = 0; i < 26; i ++){
  16. if(arr[i] > maximum) maximum = arr[i];
  17.  
  18. }
  19. return maximum;
  20.  
  21. }
  22.  
  23.  
  24. int countUpperLetters(vector<string> v){
  25. array<int, 26> alphabet = {0};
  26. for(int i = 0; i < v.size(); i++){
  27. for(char c: v[i]){
  28. if (isalpha(c) && isupper(c)) {
  29.  
  30. alphabet[c-'A']++;
  31. }
  32. }
  33. }
  34. return maxx(alphabet);
  35. }
  36.  
  37. int countLowerLetters(vector<string> v){
  38. array<int, 26> alphabet = {0};
  39. for(int i = 0; i < v.size(); i++){
  40. for(char c: v[i]){
  41. if (isalpha(c) && islower(c)) {
  42. alphabet[c-'a']++;
  43. }
  44. }
  45. }
  46. return maxx(alphabet);
  47. }
  48.  
  49. void readInput(vector<string> &odds, vector<string> &evens ) {
  50. string input;
  51. while (getline(cin, input)) {
  52. if (input.empty()) break;
  53. if(input.size() % 2 == 0)
  54. evens.push_back(input);
  55. else
  56. odds.push_back(input);
  57.  
  58. }
  59. }
  60.  
  61. int main() {
  62. vector<string> evens;
  63. vector<string> odds;
  64. string input;
  65. while (getline(cin, input)) {
  66. if (input.empty()) break;
  67. if(input.size() % 2 == 0)
  68. evens.push_back(input);
  69. else
  70. odds.push_back(input);
  71. }
  72.  
  73. cout << countLowerLetters(evens) << " " << countUpperLetters(odds) << endl;
  74.  
  75. return 0;
  76. }
Success #stdin #stdout 0.01s 5280KB
stdin
JoHn
BRuNo
KAMiL
ANna
MAGDA
stdout
2 3