一、测试程序:
1 /*
2 * 最长上升子系列长度
3 *
4 */
5
6 #include <stdio.h>
7 #include <string.h>
8
9 int main()
10 {
11 int out[1024] = {0};
12 int d[1024] = {0};
13 int cnt = 0;
14
15 while (~scanf("%d", &cnt)) {
16 int len = 0;
17 int i = 0;
18 int j = 0;
19
20 for (; i<cnt; i++)
21 scanf("%d", &d[i]);
22
23 int max = 0;
24 out[0] = d[0];
25 for (i=1; i<cnt; i++) {
26 if (d[i] > out[max])
27 out[++max] = d[i];
28 else
29 for (j=0; j<=max; j++) {
30 if (d[i] < out[j]) {
31 out[j] = d[i];
32 break;
33 }
34 }
35 }
36
37 printf("max: %d
", max+1);
38 for (i=0; i<=max; i++)
39 printf("%d ", out[i]);
40 }
41
42 return 0;
43 }