fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4. #include <cctype>
  5. #include <array>
  6. using namespace std;
  7.  
  8. int maxx(array<int,26> arr){
  9. int maximum = 0;
  10. for(int i = 0; i < 26; i ++){
  11. if(arr[i] > maximum) maximum = arr[i];
  12. }
  13. return maximum;
  14. }
  15.  
  16. int countUpperLetters(vector<string> v) {
  17. array<int, 26> alphabet = {0};
  18. for(int i = 0; i < v.size(); i++) {
  19. for(char c: v[i]) {
  20. if (isalpha(c) && isupper(c)) {
  21. alphabet[c - 'A']++; // Count uppercase letters
  22. }
  23. }
  24. }
  25. return maxx(alphabet);
  26. }
  27.  
  28. int countLowerLetters(vector<string> v) {
  29. array<int, 26> alphabet = {0};
  30. for(int i = 0; i < v.size(); i++) {
  31. for(char c: v[i]) {
  32. if (isalpha(c) && islower(c)) {
  33. alphabet[c - 'a']++; // Count lowercase letters
  34. }
  35. }
  36. }
  37. return maxx(alphabet);
  38. }
  39.  
  40. int main() {
  41. vector<string> evens;
  42. vector<string> odds;
  43. string input;
  44.  
  45. // Your logic to fill the vectors with input strings
  46. while (getline(cin, input)) {
  47. if (input.empty()) break;
  48. if(input.size() % 2 == 0)
  49. evens.push_back(input);
  50. else
  51. odds.push_back(input);
  52. }
  53.  
  54. cout << countLowerLetters(evens) << " " << countUpperLetters(odds) << endl;
  55.  
  56. return 0;
  57. }
  58.  
Success #stdin #stdout 0.01s 5244KB
stdin
JoHn
BRuNo
KAMiL
ANna
MAGDA
stdout
2 3