//子串和子序列的区别是子串是连续的,子序列可以不连续
#include
#include
using namespace std;
void MaxOrderedSub(const vector
{
int num=data.size();
//用辅助数组记录以i结尾最长子串长度
vector
for(int i=1;i
if(data[i]>data[i-1])
array[i]=array[i-1]+1;
}
int result=0;
int last=0;
//找到array中的最大值便是最长序列长
//last为这array中的下标,也就是最长序列的终点
for(int k=0;k
if(array[k]>result)
{
result=array[k];
last=k;
}
}
cout<<"the long of the sequence:"< for(int j=last;array[j]!=1;j--); int main() 作者“冒大烟的羊肉串的专栏”
for(i=j;i<=last;i++)
cout< cout<
{
cout<<"input the size of the array:"<
cin>>num;
vector
for(int i=0;i
MaxOrderedSub(arr);
return 1;
}