题目
题目描述
7.19(是否排好序了?)编写以下方法,如果参数中的list数组已经排好序了则返回true:
public static boolean isSorted(int[] list)
编写一个测试程序,提示用户输入一个列表,显示该列表是否已经排好序
注意,输入的第一个数表示列表中的元素个数,该数不是列表的一部分
运行示例:
Enter the size of the list: 8
Enter the contents of the list: 10 1 5 16 61 9 11 1
The list has 8 integers 10 1 5 16 61 9 11 1
The list is not sorted
Enter the size of the list: 10
Enter the contents of the list: 1 1 3 4 4 5 7 9 11 21
The list has 10 integers 1 1 3 4 4 5 7 9 11 21
The list is already sorted
Enter the size of the list: 10
Enter the contents of the list: 10 9 8 7 6 5 4 3