import java.util.Arrays;
import java.util.*;
public class Test{
public static void find1(int[] a)
{
int length = a.length;
int[] list = new int[length];// 存储第i个元素之前的最长递增序列值
List<Integer> result = new
ArrayList<Integer>(); // 存储最长递增序列
for (int i = 0; i < length; i++)
{
list[i] = 1;
for (int j = 0; j < i; j++)
{
if (a[j] < a[i] && list[j] + 1
> list[i])
{
list[i] = list[j] + 1;
if (result.isEmpty())
{
result.add(list[j]);
}
if (!result.contains(list[i]))
{
result.add(list[i]);
}
}
}
}
int max = list[0];
for (int i = 0; i < length; i++)
{
if (list[i] > max)
{
max = list[i];
}
}
System.out.println("最长递增序列长度:" + max);
System.out.println("最长递增序列:" + result);
}
public static void main(String[] args)
{ int [] A={1,-1,2,-2,3};
find1(A);
}
}