// The difference between a sub-string and a sub-sequence is that the sub-string is continuous and the sub-sequence can be discontinuous.
# Include <iostream>
# Include <vector>
Using namespace std;
Void MaxOrderedSub (const vector <int> & data)
{
Int num = data. size ();
// Use an auxiliary array to record the length of the oldest string ending with I
Vector <int> array (num, 1 );
For (int I = 1; I <num; I ++)
{
If (data [I]> data [I-1])
Array [I] = array [I-1] + 1;
}
Int result = 0;
Int last = 0;
// Find the maximum value in array, which is the longest sequence length.
// Last is the subscript in the array, that is, the end point of the longest sequence.
For (int k = 0; k <num; k ++)
{
If (array [k]> result)
{
Result = array [k];
Last = k;
}
}
Cout <"the long of the sequence:" <result <endl;
Cout <"the sequence:" <endl;
For (int j = last; array [j]! = 1; j --);
For (I = j; I <= last; I ++)
Cout <data [I] <"";
Cout <endl;
}
Int main ()
{
Cout <"input the size of the array:" <endl;
Int num;
Cin> num;
Vector <int> arr (num, 0 );
For (int I = 0; I <num; I ++)
Cin> arr [I];
MaxOrderedSub (arr );
Return 1;
}
Author: "The column of the catalogue with big smoke"