Advertisement
madidino

teza2-sub3-1

Nov 12th, 2023 (edited)
659
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.01 KB | None | 0 0
  1.  
  2. #include <iostream>
  3. #include <cstring>
  4. using namespace std;
  5.  
  6. int main()
  7. {
  8.     char s[101];
  9.     cin.get(s,101);
  10.     int v[26],V[26];
  11.     for(int i=0; i<=26; i++)
  12.     {
  13.         v[i]=0;
  14.         V[i]=0;
  15.     }
  16.     for(int i=0; i<strlen(s); i++)
  17.     {
  18.         if(s[i]!=' ')
  19.         {
  20.             if(s[i]>='a' && s[i]<='z')
  21.             {
  22.                 v[s[i]-'a']++;
  23.             }
  24.             else
  25.             {
  26.                 V[s[i]-'A']++;
  27.             }
  28.         }
  29.     }
  30.     char chr;
  31.     int mx=-1;
  32.     for(int i=0; i<=26; i++)
  33.     {
  34.         if(v[i]>mx)
  35.         {
  36.             mx=v[i];
  37.         }
  38.         if(V[i]>mx)
  39.         {
  40.             mx=V[i];
  41.         }
  42.     }
  43.     for(int i=0; i<=26; i++)
  44.     {
  45.         if(v[i]==mx)
  46.         {
  47.             cout<<(char)(i+'a');
  48.         }
  49.         else
  50.         {
  51.             if(V[i]==mx)
  52.             {
  53.                 cout<<(char)(i+'A');
  54.             }
  55.         }
  56.     }
  57.     cout<<" "<<mx;
  58.     return 0;
  59. }
  60.  
  61. //Voi da Bacalaureatul la Informatica
  62.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement