Implementing permuted index in C++ I have implemented a program that produces a permuted index.
Actually it is this exercise:
https://stackoverflow.com/questions/4015016/what-is-a-permuted-index

Could anyone tell me if I did something wrong, and if it could be done better?

An input is for example:

The quick brown fox


And result:

      The quick     brown fox 
The quick brown     fox 
            The     quick brown fox 
                    The quick brown fox


main.cpp

#include "myImplementation.cpp"

using namespace std;

vector&lt;string&gt; split(const string &amp;s) {
    vector&lt;string&gt; ret;
    string::size_type i = 0;
    while (i != s.size()) {
        while (i != s.size() &amp;&amp; isspace(s[i]))
            ++i;
        string::size_type j = i;
        while (j != s.size() &amp;&amp; !isspace(s[j]))
            j++;
        if (i != j) {
            ret.push_back(s.substr(i, j - i));
            i = j;
        }
    }
    return ret;
}

int main() {
    string phrase;
    cout &lt;&lt; "Please give me some phrase" &lt;&lt; endl;
    getline(cin, phrase);

    vector &lt;string&gt; splitted = split(phrase);

    vector&lt;string&gt; permuted = makePermutedIndex(splitted);

    for (const auto i : permuted) {
        cout &lt;&lt; i &lt;&lt; endl;
    }

    return 0;
}


myImplementation.cpp

#include &lt;vector&gt;
#include &lt;sstream&gt;
#include &lt;algorithm&gt;

using namespace std;

vector&lt;string&gt; concatLeftAndRight(const vector&lt;string&gt; &amp;left, const vector&lt;string&gt; &amp;right,
                                  const string::size_type maxLengthOfLeftLine) {
    vector&lt;string&gt; ret;
    for (vector&lt;string&gt;::size_type i = 0; i != left.size(); ++i) {
        std::stringstream ss;
        ss &lt;&lt; string(maxLengthOfLeftLine - left[i].size(), ' ')
        &lt;&lt; left[i] &lt;&lt; "   " &lt;&lt; right[i];
        ret.push_back(ss.str());
    }
    return ret;
}


vector&lt;string&gt; makePermutedIndex(const vector&lt;string&gt; &amp;splitted) {

    vector&lt;string&gt; sorted(splitted);

    std::sort(sorted.begin(), sorted.end());

    string::size_type maxLengthOfLeftLine = 0;

    vector&lt;string&gt; left;
    vector&lt;string&gt; right;

    for (auto index : sorted) {
        string rightLine, leftLine;
        bool indexEncountered = false;

        for (auto word : splitted) {
            if ((index != word) &amp;&amp; !indexEncountered) {
                leftLine += word;
                leftLine += " ";
            }
            else {
                indexEncountered = true;
                rightLine += word;
                rightLine += " ";
            }
        }
        maxLengthOfLeftLine = max(maxLengthOfLeftLine, leftLine.size());
        left.push_back(leftLine);
        right.push_back(rightLine);
    }
    return concatLeftAndRight(left, right, maxLengthOfLeftLine);
}
The code does not implement the permuted index. Instead of

      The quick     brown fox 
The quick brown     fox 
            The     quick brown fox 
                    The quick brown fox


it produces

                   The quick brown fox 
      The quick    brown fox 
The quick brown    fox 
            The    quick brown fox 


Notice that the order is wrong. The permuted index shall be sorted by the second column.
using namespace std; is considered bad practice.
Never #include a .cpp file. See for example this discussion for details.
Try not use so many strings. It hurts both memory usage and performance. In fact there is no need to break the initial string into words and reconstruct left and right strings. A vector of whitespace locations in the original string suffices.