POJ2533
#include <STDIO.H>
#include <MALLOC.H>
#define max(a, b) (((a) > (b)) ? (a) : (b))
void GetMaxIncLen(int
*data, int *maxLen, int size)
{
int i, j;
for(i = 2; i <= size;
i++)
{
for(j = 1; j < i; j++)
{
if(data[j] <
data[i])
{
maxLen[i] = max(maxLen[i], maxLen[j] +
1);
}
}
}
}
void main()
{
int i, size, max;
int *data = NULL;
int *maxLen
= NULL;
scanf("%d", &size);
data = (int *)malloc(sizeof(int) * (size
+ 1));
maxLen = (int *)malloc(sizeof(int) * (size + 1));
memset(data, 0,
sizeof(int) * (size + 1));
memset(maxLen, 0, sizeof(int) * (size +
1));
for(i = 1; i <= size; i++)
{
scanf("%d",
&data[i]);
maxLen[i] = 1;
}
GetMaxIncLen(data,
maxLen, size);
max = 0;
for(i = 1; i <= size;
i++)
{
if(maxLen[i] > max)
{
max =
maxLen[i];
}
}
printf("%d", max);
}
原文地址:http://www.cnblogs.com/jsy306/p/3729282.html