OpenJudge1759:最长上升子序列
犯了两个错误
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
int a[1010], b[1010] = { 0 };//错误二:用memset()把b数组内容置为1;
int main() {
int n;
cin >> n;
for (int i = 0; i < n; i++) {
cin >> a[i];
}
for (int i = 1; i < n; i++) {
for (int j = 0; j < i; j++) {//错误一:把j++打成i++
if (a[i] > a[j]) {
b[i] = max(b[i], b[j] + 1);
}
}
}
int maxx = 0;
for (int i = 0; i < n; i++) {
if (maxx < b[i])
maxx = b[i];
}
printf("%d", maxx+1);
return 0;
}