哈理工软件学院第三届ACM编程决赛-高年级组B.Is Sorted

输入完再判断
import java.util.Scanner;

public class Main {

	@SuppressWarnings("resource")
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int T = scan.nextInt();
		while (T-- != 0) {
			int n = scan.nextInt();
			int pre = Integer.MIN_VALUE;
			int flag = 0;
			for (int i = 0; i < n; ++i) {
				int cur = scan.nextInt();
				if (cur <= pre) {
					flag = 1;
				}
				pre = cur;
			}
			if (flag == 0) {
				System.out.println("Yes");
			} else {
				System.out.println("No");
			}
		}
	}
}

猜你喜欢

转载自blog.csdn.net/qq_39370495/article/details/89329677