#include <iostream> using namespace std; #define MAXSIZE 100 int max(int num1, int num2) { return num1>num2?num1:num2; } int main() { int num[MAXSIZE]; int maxLen[MAXSIZE] = {1}; int n; int i; int j; cin >> n; for (i=0; i<n; i++) cin >> num[i]; for (i=1; i<n; i++) for (j=0; j<i-1; j++) { if (num[i] > num[j]) maxLen[i] = max(maxLen[j], maxLen[i]+1); else maxLen[i] = max(maxLen[i], maxLen[j]); } cout << maxLen[n-1] << endl; return 0; }
原文:http://www.cnblogs.com/jlbs/p/6485883.html