Advertisement
dyamondz

Control C202C - P12943

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