算法思想:初试设最长递增长度max为-1,递增序列个数为1,初值A[0]设为temp,并与后继元素比较,如果后面的元素比当前元素大,则个数加1,否则当前个数与max比较,取最大者为新max,并且temp设为当前的元素,继续比较直到遍历结束。
int maxLCS(ElemType A[], int n){
int(n<=1) return n;
int count = 1, maxcount = 0;
ElemType temp = A[0];
for(int i = 1; i<n ;i++){
if(temp<A[i]){
count ++;
temp = A[i];
}
if(maxcount>count){
maxcount = count;
}
}
return maxcount;
}