package test;
//判断是否是非降序
public class Nojiangxu {
public static void main(String[] args) {
int A[] = { 1, 2, 4, 3, 0 };
int n = A.length;
int i = 0;
int count = 0;
while (i < n - 1) {
if (A[i] <= A[i + 1] && i < n - 1) {
i = i + 1;
count++;
} else break;
}
if (count == n-2) {
System.out.println("ture");
}
else System.out.println("flase");
}
}
时间复杂度为:O(n)