package java_a3.pkg1;
/**
*
* @author martin4dream
*/
public class Java_A31 {
public static void main(String[] args) {
int a[] = {13,23,43,7,67,3,76,35,897,70,567,33,52346,23,555,1,2,3,4,5,6,7,8,917,13,5,6,7,8,96,7,8,9,1,1,1,1,1,1,1,1,2};
int size = a.length;
int length = 1, maxlen = 1, startpoint = 0;
int i;
for(i=1; i<=size-1; i++) {
if(a[i-1]<=a[i]) { /* 递增"<=",递减">=" */
length++;
}
else {
if(length > maxlen) {
maxlen = length;
startpoint = i - length;
}
length = 1;
}
}
if(length > maxlen) {
maxlen = length;
startpoint = i - length;
}
System.out.print("至少存在最长递增子数组是:[");
for(i=0; i
System.out.print(a[startpoint+i] + " ");
}
System.out.println("\b]");
}
}