18 lines
401 B
C++
18 lines
401 B
C++
#include "common.h"
|
|
|
|
|
|
std::vector<std::string> split(const std::string& s, char sp) {
|
|
size_t i = 0, l = 0;
|
|
std::vector<std::string> res;
|
|
while (i < s.size()) {
|
|
if (s[i] == sp) {
|
|
if (i != l)
|
|
res.push_back(s.substr(l, i - l));
|
|
l = i + 1;
|
|
}
|
|
i++;
|
|
}
|
|
if (i != l)
|
|
res.push_back(s.substr(l, i - l));
|
|
return res;
|
|
} |