fork download
  1. #include <cstring>
  2. #include <iostream>
  3.  
  4. int strcc(const char* str)
  5. {
  6. int c = 0;
  7. int o_c = 0;
  8. int len = strlen(str);
  9. for(int i = 0; i < len; i++)
  10. {
  11. if(str[i] == 'o' || str[i] == 'O')
  12. {
  13. c++;
  14. if(c == 2)
  15. {
  16. o_c++;
  17. }
  18. }
  19. else if(str[i] == ' ' || str[i] == '\t') c = 0;
  20. }
  21. return o_c;
  22. }
  23.  
  24. using namespace std;
  25.  
  26. int main(int argc, char** argv)
  27. {
  28. const char* str = "ololol asdf o asdf lol asdf oo";
  29. cout << strcc(str) << endl;
  30. return 0;
  31. }
Success #stdin #stdout 0s 3340KB
stdin
Standard input is empty
stdout
2