Advertisement
rotti321

Teza 2 SIII ex 1

Jun 7th, 2021
936
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <iostream>
  2. #include <cstring>
  3.  
  4. using namespace std;
  5.  
  6. int main(){
  7.   char s[101]={};
  8.   int v[60]={},cod,maxx=0,cnt;
  9.   cin.getline(s,101);
  10.   //gasesc frecventa maxima pt o litera
  11.   for(char ch='a';ch<='z';ch++){
  12.       cnt=0;
  13.       for(int i=0;i<strlen(s);i++){
  14.           if(ch==s[i]) cnt++;
  15.       }
  16.       if(cnt>maxx) maxx=cnt;
  17.   }
  18.   for(char ch='A';ch<='Z';ch++){
  19.       cnt=0;
  20.       for(int i=0;i<strlen(s);i++){
  21.           if(ch==s[i]) cnt++;
  22.       }
  23.       if(cnt>maxx) maxx=cnt;
  24.   }
  25.   cout<<maxx<<endl;
  26.   //afisez literele cu frecventa maxima
  27.   for(char ch='a';ch<='z';ch++){
  28.       cnt=0;
  29.       for(int i=0;i<strlen(s);i++){
  30.           if(ch==s[i]) cnt++;
  31.       }
  32.       if(cnt==maxx) cout<<ch;
  33.   }
  34.   for(char ch='A';ch<='Z';ch++){
  35.       cnt=0;
  36.       for(int i=0;i<strlen(s);i++){
  37.           if(ch==s[i]) cnt++;
  38.       }
  39.       if(cnt==maxx) cout<<ch;
  40.   }  
  41. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement