Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <vector>
- #include <string>
- #include <iostream>
- std::vector<std::pair<char*, int> > split(char* start, int length, int depth) {
- bool continueSplitting = depth < 4;
- std::vector<std::pair<char*, int> > retval;
- if (!continueSplitting){
- retval.push_back(std::make_pair(start, length));
- return retval;
- }
- //find the midpoint here using the operation I described
- int newlineIndex;
- std::vector<std::pair<char*, int> > leftResult = split(start, newlineIndex + 1, depth + 1);
- for (int i = 0; i < leftResult.size(); i++)
- retval.push_back(leftResult[i]);
- std::vector<std::pair<char*, int> > rightResult = split(start + newlineIndex + 1, length - newlineIndex - 1, depth + 1);
- for (int i = 0; i < rightResult.size(); i++)
- retval.push_back(rightResult[i]);
- return retval;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement