fork download
  1. #include <iostream>
  2. #include <string>
  3. #include <vector>
  4.  
  5. using namespace std;
  6.  
  7.  
  8. vector<string> explode(const string &delimiter, const string &str)
  9. {
  10. vector<string> arr;
  11.  
  12. int strleng = str.length();
  13. int delleng = delimiter.length();
  14. if (delleng == 0)
  15. return arr;//no change
  16.  
  17. int i = 0;
  18. int k = 0;
  19. while (i<strleng)
  20. {
  21. int j = 0;
  22. while (i + j<strleng && j<delleng && str[i + j] == delimiter[j])
  23. j++;
  24. if (j == delleng)//found delimiter
  25. {
  26. arr.push_back(str.substr(k, i - k));
  27. i += delleng;
  28. k = i;
  29. }
  30. else
  31. {
  32. i++;
  33. }
  34. }
  35. arr.push_back(str.substr(k, i - k));
  36. return arr;
  37. }
  38.  
  39.  
  40. int main() {
  41. // your code goes here
  42. /*string str = "(Headlights,NOVALUE,Session,ProductVersion,15.0.0)";
  43. str = str.substr(1,str.size()-2);
  44. vector<string> v = explode(",",str);
  45. for (int i = 0; i<v.size(); i++)
  46. cout<<v[i]<<endl;*/
  47. string a = "abc";
  48. string b = "def";
  49. string c = "ghi";
  50. string d = a+b + c;
  51. cout<<d;
  52. return 0;
  53. }
Success #stdin #stdout 0s 3460KB
stdin
Standard input is empty
stdout
abcdefghi