Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- int main() {
- int n;
- cin >> n;
- int na=0;
- int nb=0;
- int nc=0;
- for (int i=n; i>0; --i) {
- char s;
- cin >> s;
- if (s == 'a') ++na;
- else if (s == 'b') ++nb;
- else if (s == 'c') ++nc;
- }
- int max;
- if (na > nb and na > nc) max=na;
- else if (nb > nc) max=nb;
- else max=nc;
- char sortida;
- if (max==na) sortida = 'a';
- else if (max==nb) sortida = 'b';
- else sortida = 'c';
- cout << "majoria de " << sortida << endl << max << " repeticio(ns)" << endl;
- }
Add Comment
Please, Sign In to add comment