fork download
  1. #include <iostream>
  2. #include <vector>
  3.  
  4. using namespace std;
  5.  
  6. int main(void)
  7. {
  8. vector<string> sentences;{
  9. string temp;
  10. while(!cin.eof()){
  11. cin>>temp;
  12. sentences.push_back(temp);
  13. }
  14. }
  15. vector<int> count(26,0);
  16.  
  17. for(size_t i=0;i<sentences.size();++i)
  18. for(size_t j=0;j<sentences[i].length();++j)
  19. count[static_cast<int>(sentences[i][j])-97]++;
  20.  
  21. int max=0;
  22.  
  23. for(int i=0;i<26;++i)
  24. if(max<count[i])
  25. max=count[i];
  26. for(int i=0;i<26;++i)
  27. if(count[i]==max)
  28. cout<<static_cast<char>(i+97);
  29. return 0;
  30. }
  31.  
Success #stdin #stdout 0s 15240KB
stdin
aa b


stdout
ab