fork(2) download
  1. #include<bits/stdc++.h>
  2. using namespace std;
  3.  
  4.  
  5. char max_count(char *str)
  6. {
  7.  
  8. int count[256] = {0};
  9.  
  10. int len = strlen(str);
  11. int max = 0;
  12. char result;
  13. for (int i = 0; i < len; i++) {
  14. count[str[i]]++;
  15. if (max < count[str[i]]) {
  16. max = count[str[i]];
  17. result = str[i];
  18. }
  19. }
  20.  
  21. return result;
  22.  
  23. }
  24. int main() {
  25.  
  26. string str;
  27. cin>>str;
  28.  
  29. cout<<max_count(str);
  30.  
  31. return 0;
  32. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
aabbbbcccccccc
compilation info
prog.cpp: In function ‘int main()’:
prog.cpp:29:20: error: cannot convert ‘std::__cxx11::string’ {aka ‘std::__cxx11::basic_string<char>’} to ‘char*’
    cout<<max_count(str);
                    ^~~
prog.cpp:5:22: note:   initializing argument 1 of ‘char max_count(char*)’
 char max_count(char *str)
                ~~~~~~^~~
stdout
Standard output is empty