fork(10) download
  1. #include <iostream>
  2. #include <string>
  3. using namespace std;
  4.  
  5. int main(int argc, const char * argv[]) {
  6. // insert code here...
  7.  
  8. string separator{" \t\r\n,.!?;:"};
  9. string line;
  10. string word;
  11. while(getline (cin, line)){ // read line by line
  12. size_t e,s=0;
  13. do {
  14. s = line.find_first_not_of(separator,s);
  15. if (s==string::npos)
  16. break;
  17. e=line.find_first_of(separator, s);
  18. string word(line.substr(s,e-s));
  19. cout<<word<<endl;
  20. s=e+1;
  21. } while (e!=string::npos);
  22. }
  23.  
  24. return 0;
  25. }
  26.  
Success #stdin #stdout 0s 16064KB
stdin
   I don't have , power, but he has power.
stdout
I
don't
have
power
but
he
has
power