C++ Beginner. Project Euler 14: Longest Collatz sequence under one million
I will try and tackle correctness, style and performance in that order

Corectness

My initial guess, for wrong results would be you are overflowing an int for long sequences. making x0 an unsigned long I get the longest sequence as 524, for 837799, which matches the results at https://www.dcode.fr/collatz-conjecture . Indeed that sequence contains 2974984576 which will overflow a signed int.

Style

Your code is very c-like and has not really used any c++ features other than cout. Some things I would change:


avoid using namespace std, see https://stackoverflow.com/questions/1452721/why-is-using-namespace-std-considered-bad-practice This is generally considered bad practise as it you can get unexpected name collisions. It probably won't cause any real issues on a small project like this, but is a bad habit to get into.
Prefer stl containers to raw arrays. Stl containers have many advantages over raw arrays. In your case I would make k a std::array, i.e. std::array&lt; std::size_t,  n-2 &gt; k; std::arrays are fixed size containers very similar to raw arrays, but don't decay to pointers, provide iterators and to allow easily looping over the elements ( and interacting with the rest of the stl ), among other features.
Your update of x0 is not very clear/easy to read. I would break this into the two cases with and if/else, and probably make it a separate function. i.e.


if( x0%2 )
{
    x0 = 3*x0 + 1;
}
else
{
    x0 = x0/2;
}



Use stl functions rather than writing your own. Another advantage of using stl containers is there are many standard functions that use the containers, which can save you having to write your own. e.g. std::max_element this could simplify your calculation of max value and index.


auto maxIt = std::max_element(k.begin(), k.end());
int maxSeq = std::distance(k.begin(), maxIt) + 2;
unsigned long maxValue = k[maxSeq - 2];



Make values unsigned if they cannot be &lt; 0. None of your values should be &lt;0, for clarity it is good practise to make them in this case. The normal way to do this for ints is to use std::size_t. This helps clarify the intent of your code.


Performance

Your code seems to have pretty good performance and has no trivial performance improvements that I can see. Possibly the updating of x0 can be written more efficiently, but I would change it for clarity reasons, as mentioned above, and profile any possible performance changes from there. 

I will note that the sequence does not depend on previous values, so if you reach a value already calculated k for you do not need to calculate the rest of the sequence, but can just add that value. Again you would need to profile whether the cost of doing the extra checks gives an actual improvement.