fork download
  1. #include <iostream>
  2. #include <sstream>
  3. #include <algorithm>
  4. #include <cstring>
  5. using namespace std;
  6.  
  7. bool is_seperator (char ch) {
  8. return strchr(",!?", ch) != NULL;
  9. }
  10.  
  11. int main() {
  12. string line;
  13. getline(cin, line);
  14. replace_if(line.begin(), line.end(), is_seperator, ' ');
  15. stringstream words(line);
  16. string word;
  17. int i = 1;
  18. while (words >> word) {
  19. cout << i++ << ". " << word << endl;
  20. }
  21. return 0;
  22. }
  23.  
Success #stdin #stdout 0s 3468KB
stdin
Привет, Мир!Как,дела-то у тебя?
stdout
1. Привет
2. Мир
3. Как
4. дела-то
5. у
6. тебя