Guest User

Untitled

a guest
May 25th, 2018
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <iostream>
  2. using namespace std;
  3.  
  4. int main() {
  5. int n;
  6. cin >> n;
  7. int na=0;
  8. int nb=0;
  9. int nc=0;
  10.  
  11. for (int i=n; i>0; --i) {
  12. char s;
  13. cin >> s;
  14. if (s == 'a') ++na;
  15. else if (s == 'b') ++nb;
  16. else if (s == 'c') ++nc;
  17. }
  18.  
  19. int max;
  20. if (na > nb and na > nc) max=na;
  21. else if (nb > nc) max=nb;
  22. else max=nc;
  23.  
  24. char sortida;
  25. if (max==na) sortida = 'a';
  26. else if (max==nb) sortida = 'b';
  27. else sortida = 'c';
  28. cout << "majoria de " << sortida << endl << max << " repeticio(ns)" << endl;
  29. }
Add Comment
Please, Sign In to add comment