Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.*;
- import java.io.* ;
- public class Lab8Part6 {
- public static void main(String[] args) {
- double[] a1 = {16.1, 25.3, 12.2, 44.4};
- double[] a2 = {1.5, 4.3, 7.0, 19.5, 25.1,
- 46.2};
- double[] a3 = {42.0};
- System.out.println(isSorted(a1)); // false
- System.out.println(isSorted(a2)); // true
- System.out.println(isSorted(a3)); // true
- }
- public static isSorted(double[] list){
- for (int i = 0; int i <= list.length-2; i++){
- if (list[i] > list[i+1] ){
- return false;
- break;
- }
- else{
- return true;
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement