C++ reading a sequence of integers
<p>gooday programers. I have to design a C++ program that reads a sequence of positive integer values that ends with zero and find the length of the longest increasing subsequence in the given sequence. For example,  for the following 
sequence of integer numbers:</p>

<pre><code>1 2 3 4 5 2 3 4 1 2 5 6 8 9 1 2 3 0
</code></pre>

<p>the program should return 6 
i have written my code which seems correct but for some reason is always returning zero, could someone please help me with this problem. </p>

<p>Here is my code: </p>

<pre><code>#include &lt;iostream&gt; 
using namespace std; 

int main() 
{ 
    int x = 1;          // note x is initialised as one so it can enter the while loop
    int y = 0; 
    int n = 0;

    while (x != 0)          // users can enter a zero at end of input to say they have entered all their numbers
    { 
        cout &lt;&lt; "Enter sequence of numbers(0 to end): ";
        cin &gt;&gt; x; 
        if (x == (y + 1))   // &lt;&lt;&lt;&lt;&lt; i think for some reason this if statement if never happening 
        { 
            n = n + 1;
            y = x;
        } 
        else 
        {
            n = 0;
        }
    } 
    cout &lt;&lt; "longest sequence is: " &lt;&lt; n &lt;&lt; endl;
    return 0; 
}
</code></pre>
