fork download
  1. #include <iostream>
  2. #include <cctype>
  3.  
  4. void output_words(std::ostream& _out, const char* s){
  5. int m = 0, n = 0;
  6. char t, c = '\0';
  7. do {
  8. if(! isalpha(*s)){
  9. if((m > 1) && (m == n)){
  10. _out.write(s - m, m);
  11. _out << std::endl;
  12. }
  13. c = '\0';
  14. n = m = 0;
  15. } else {
  16. t = toupper(*s);
  17. m += (int)(t >= c);
  18. c = t;
  19. ++n;
  20. }
  21. } while(*s++ != '\0');
  22.  
  23. _out.flush();
  24. }
  25.  
  26.  
  27. int main(void){
  28. char s[] = "Abc def cba AbCdEfff AXBCZ (OPS) Xyz A AD";
  29. output_words(std::cout, s);
  30. return 0;
  31. }
Success #stdin #stdout 0s 3456KB
stdin
Standard input is empty
stdout
Abc
def
AbCdEfff
OPS
Xyz
AD