#includeusing namespace std;//method1/*利用动态规划来求解。假设目标数组array[]的前i个元素中,最长递增子序列的长度为LIS[i].那么,LIS[i]=max{1,LIS[k]+1},array[i+1]>array[k],for any k<=i时间复杂度为O(N^2)*/int findLongest(int* A,int N){ int* LIS=new int[N]; int max=0; for(int i=0;i A[j] && LIS[j]+1>LIS[i]) { LIS[i]=LIS[j]+1; } } for(int i=0;i max)max=LIS[i]; } delete [] LIS; return max;}int main(){ int N; int* A; while(cin>>N,N) { A=new int[N]; for(int i=0;i >A[i]; int max=findLongest(A,N); cout<<"数组中最长递增子序列长度为:"< <