Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class Main {
- public static void main(String[] args) {
- Scanner s = new Scanner(System.in);
- int N = Integer.parseInt(s.nextLine());
- //create array of booleans
- String[] answers = new String[N];
- //keep all answers in array
- for (int i = 0; i < N; i++) {
- Scanner sd = new Scanner(System.in);
- String StringInput = sd.nextLine();
- //create array of Strings
- String[] ArrStrings = StringInput.split(",");
- //create sorted Array and keep clone of original Array, change both arrays to strings and compare them
- String a = "true";
- for (int j = 0; j < ArrStrings.length - 1; j++) {
- int num1 = Integer.parseInt(ArrStrings[j]);
- int num2 = Integer.parseInt(ArrStrings[j + 1]);
- if (num1 > num2) {
- a = "false";
- break;
- }
- }
- answers[i] = a;
- }
- //print answers elements
- for (int ij = 0; ij < answers.length; ij++) {
- System.out.println(answers[ij]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement