Advertisement
Guest User

123

a guest
Sep 20th, 2017
86
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.57 KB | None | 0 0
  1. #include <string>
  2. #include <stdexcept>
  3.  
  4. using namespace std;
  5.  
  6. vector<string> Split(const string& str, const string& delim = " ") {
  7.     vector<string> answer;
  8.     int begword = 0;
  9.     int endword = 0;
  10.     while(str.find(delim, endword) != str.npos)
  11.     {
  12.         begword = str.find(delim, endword);
  13.         if(str.find(delim, begword) == str.npos)
  14.         {
  15.             int sz = str.size();
  16.             endword = sz;
  17.         }
  18.         else
  19.             endword = str.find(delim, begword);
  20.         answer.push_back(str.substr(begword, endword - begword));
  21.         endword--;
  22.     }
  23.     return answer;
  24.     throw std::runtime_error("Not implemented");
  25. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement