fork download
  1. #include <iostream>
  2. #include <cstdio>
  3. #include <string>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8. int size, povt, max_povt = 0;
  9. cin >> size;
  10. string arr[size], word;
  11. for (int i = 0; i < size; i++){
  12. cin >> arr[i];
  13. }
  14.  
  15. for (int i = 0; i < size - 1; i++){
  16. for(int j = i + 1; j < size; j++){
  17. if (arr[i] == arr[j]){
  18. povt ++;
  19. }
  20. if (povt > max_povt){
  21. max_povt = povt;
  22. word = arr[i];
  23. }
  24. }
  25. }
  26.  
  27. cout << word;
  28.  
  29. return 0;
  30. }
Success #stdin #stdout 0s 5292KB
stdin
5
qw
qwe
qw
qwe
qwe
stdout
qwe