Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <iostream>
- #include <string>
- #include <vector>
- using std::cout;
- using std::cin;
- using std::vector;
- using std::string;
- void Input(string *line, char &symbol) {
- cin >> *line >> symbol;
- }
- vector<string> Split(string const &line, char symbol) {
- vector<string> result;
- for (int s(0), j(0), i(0); i < line.size(); ++i) {
- if (line[i] == symbol) {
- result.push_back(line.substr(j , (i - j)));
- j = i + 1;
- ++s;
- }
- if (i == line.size() - 1) {
- result.push_back(line.substr(j , (i - j + 1)));
- }
- }
- return result;
- }
- void Output(vector<string> &answer) {
- for(vector<string>::iterator i = answer.begin(); i != answer.end(); ++i) {
- cout << *i << "\n";
- }
- }
- int main() {
- string line;
- char symbol;
- Input(&line, symbol);
- Output(Split(line, symbol));
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement