Advertisement
CyberN00b

Untitled

Nov 21st, 2021 (edited)
1,015
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.65 KB | None | 0 0
  1. #include <iostream>
  2. #include <string>
  3. #include <cstring>
  4.  
  5. using namespace std;
  6.  
  7. int main() {
  8.     string str;
  9.     getline(cin, str);
  10.     char* nstr = new char[str.size()];
  11.     strcpy(nstr, str.c_str());
  12.     int length = 0;
  13.     for (auto x : str)
  14.         if (!isalnum(x))
  15.             length++;
  16.     if (isalnum(str[str.size() - 1]))
  17.         length++;
  18.     string* arr = new string[length];
  19.     char* tmp = strtok(nstr, " .?,:;!");
  20.     for (int i = 0; i < length; ++i) {
  21.         arr[i] = tmp;
  22.         tmp = strtok(nullptr, " .?,:;!");
  23.     }
  24.     for (int i = 0; i < length; ++i) {
  25.         cout << arr[i] << ((i != length - 1)? "|" : "");
  26.     }
  27. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement