#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
template <typename OutputInserter>
void split(const string &line, OutputInserter inserter, char delim)
{
register unsigned pos_start = 0;
register unsigned pos_end = 0;
while((pos_end = line.find(delim, pos_start)) != string::npos)
{
*inserter = line.substr(pos_start, pos_end-pos_start);
pos_start = pos_end+1;
++inserter;
}
if (line.back() == delim) return;
*inserter = line.substr(pos_start);
++inserter;
}
int main()
{
string test1 = "1;2;3;4;5;6";
vector<string> splited;
split(test1, back_inserter(splited), ';');
for (auto it: splited)
cout<<it<<endl;
return 0;
}
I2luY2x1ZGUgPGlvc3RyZWFtPgojaW5jbHVkZSA8c3RyaW5nPgojaW5jbHVkZSA8dmVjdG9yPgojaW5jbHVkZSA8YWxnb3JpdGhtPgp1c2luZyBuYW1lc3BhY2Ugc3RkOwoKdGVtcGxhdGUgPHR5cGVuYW1lIE91dHB1dEluc2VydGVyPgp2b2lkIHNwbGl0KGNvbnN0IHN0cmluZyAmbGluZSwgT3V0cHV0SW5zZXJ0ZXIgaW5zZXJ0ZXIsIGNoYXIgZGVsaW0pCnsKICAgIHJlZ2lzdGVyIHVuc2lnbmVkIHBvc19zdGFydCA9IDA7CiAgICByZWdpc3RlciB1bnNpZ25lZCBwb3NfZW5kICAgPSAwOwogCiAgICB3aGlsZSgocG9zX2VuZCA9IGxpbmUuZmluZChkZWxpbSwgcG9zX3N0YXJ0KSkgIT0gc3RyaW5nOjpucG9zKQogICAgewogICAgICAgICppbnNlcnRlciA9IGxpbmUuc3Vic3RyKHBvc19zdGFydCwgcG9zX2VuZC1wb3Nfc3RhcnQpOwogICAgICAgIHBvc19zdGFydCA9IHBvc19lbmQrMTsKICAgICAgICArK2luc2VydGVyOwogICAgfQogCWlmIChsaW5lLmJhY2soKSA9PSBkZWxpbSkgcmV0dXJuOwogCSppbnNlcnRlciA9IGxpbmUuc3Vic3RyKHBvc19zdGFydCk7CiAJKytpbnNlcnRlcjsKfQppbnQgbWFpbigpIAp7CglzdHJpbmcgdGVzdDEgPSAiMTsyOzM7NDs1OzYiOwoJdmVjdG9yPHN0cmluZz4gc3BsaXRlZDsKCXNwbGl0KHRlc3QxLCBiYWNrX2luc2VydGVyKHNwbGl0ZWQpLCAnOycpOwoJZm9yIChhdXRvIGl0OiBzcGxpdGVkKSAKCQljb3V0PDxpdDw8ZW5kbDsKCXJldHVybiAwOwp9