Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- using namespace std;
- #include <algorithm>
- #include <cmath>
- #include <vector>
- #include <sstream>
- vector<string> split(const string& s) {
- vector <string> res;
- string cur = "";
- int n = s.size();
- for (int i = 0; i < n; ++i) {
- if (s[i] == ' ') {
- if (cur != "") {
- res.push_back(cur);
- cur = "";
- }
- } else {
- cur += s[i];
- }
- }
- return res;
- }
- int main()
- {
- string s;
- getline(cin, s);
- s += ' ';
- auto v = split(s);
- for (string i: v) {
- cout << i << ' ';
- } cout << "\n";
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement