Advertisement
Guest User

Untitled

a guest
Jul 17th, 2014
213
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.85 KB | None | 0 0
  1.  
  2. #include <vector>
  3. #include <string>
  4. #include <iostream>
  5.  
  6. std::vector<std::pair<char*, int> > split(char* start, int length, int depth) {
  7.   bool continueSplitting = depth < 4;
  8.  
  9.   std::vector<std::pair<char*, int> > retval;
  10.  
  11.   if (!continueSplitting){
  12.     retval.push_back(std::make_pair(start, length));
  13.     return retval;
  14.   }
  15.  
  16.   //find the midpoint here using the operation I described
  17.   int newlineIndex;
  18.    
  19.  
  20.   std::vector<std::pair<char*, int> > leftResult = split(start, newlineIndex + 1, depth + 1);
  21.  
  22.   for (int i = 0; i < leftResult.size(); i++)
  23.     retval.push_back(leftResult[i]);
  24.  
  25.   std::vector<std::pair<char*, int> > rightResult = split(start + newlineIndex + 1, length - newlineIndex - 1, depth + 1);
  26.  
  27.   for (int i = 0; i < rightResult.size(); i++)
  28.     retval.push_back(rightResult[i]);
  29.  
  30.   return retval;
  31.  
  32.  
  33.  
  34.  
  35.  
  36.  
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement