Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <cstring>
- using namespace std;
- int main() {
- string str;
- getline(cin, str);
- char* nstr = new char[str.size()];
- strcpy(nstr, str.c_str());
- int length = 0;
- for (auto x : str)
- if (!isalnum(x))
- length++;
- if (isalnum(str[str.size() - 1]))
- length++;
- string* arr = new string[length];
- char* tmp = strtok(nstr, " .?,:;!");
- for (int i = 0; i < length; ++i) {
- arr[i] = tmp;
- tmp = strtok(nullptr, " .?,:;!");
- }
- for (int i = 0; i < length; ++i) {
- cout << arr[i] << ((i != length - 1)? "|" : "");
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement