-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCheckingArray.java
More file actions
40 lines (31 loc) · 940 Bytes
/
CheckingArray.java
File metadata and controls
40 lines (31 loc) · 940 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import java.util.*;
import java.util.Scanner;
import java.util.concurrent.ForkJoinTask;
public class CheckingArray {
public static void main(String[] args) {
Scanner sc = new Scanner(System.in);
int a = sc.nextInt();
int arr[] = new int[a];
for (int b = 0; b < a; b++) {
arr[b] = sc.nextInt();
}
int flag = 1 ;
// for (int c = 0; c < a - 1; c++) {
// if (arr[c] > arr[c + 1]) {
// System.out.println("Unsorted");
// break;
// }
// }
// System.out.println("Sorted");
for(int i = 0 ; i< a -1 ; i++){
if(arr[i] > arr[i+1]){
flag = 0 ;
}
}
if(flag == 0 ){
System.out.println("unsorted");
}else{
System.out.println("sorted");
}
}
}