Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- static public boolean isSorted(int[] array) {
- boolean sorted = false;
- for (int i = 0; i < array.length - 1; i++) {
- if (array[i] <= array[i + 1])
- sorted = true;
- else {
- sorted = false;
- }
- }
- return sorted;
- }
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int times = Integer.parseInt(scanner.nextLine());
- for (int i = 0; i < times; i++) {
- String[] inputs = scanner.nextLine().split(",");
- int[] conv = new int[inputs.length];
- for (int j = 0; j < inputs.length; j++) {
- conv[j] = Integer.parseInt(inputs[j]);
- }
- System.out.println(isSorted(conv));
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment