Advertisement
rotti321

SIII Teza 2 ex 1

Jun 7th, 2021
164
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.68 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;
  9. cin.getline(s,101);
  10. for(int i=0;i<strlen(s);i++){
  11. if(s[i]>='a' && s[i]<='z'){
  12. cod=s[i]-'a'+1;/// i=ch-'a'+1 ch='a'+i-1
  13. v[cod]++;
  14. if(v[cod]>maxx) maxx=v[cod];
  15. }
  16. if(s[i]>='A' && s[i]<='Z'){
  17. cod=s[i]-'A'+27;
  18. v[cod]++;
  19. if(v[cod]>maxx) maxx=v[cod];
  20. }
  21.  
  22. }
  23. cout<<maxx<<endl;
  24. for(int i=1;i<=26;i++){
  25. if(v[i]==maxx){
  26. cout<<char(i+'a'-1);
  27. }
  28. }
  29. for(int i=27;i<=53;i++){
  30. if(v[i]==maxx){
  31. cout<<char(i+'A'-27);
  32. }
  33. }
  34. }
  35.  
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement