Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.util.Scanner;
- public class IsAListSorted {
- public static void main(String[] args) {
- Scanner scanner = new Scanner(System.in);
- int n = Integer.parseInt(scanner.next());
- if (n>=1&&n<=10){
- for(int i =0;i<=n;i++) {
- boolean isSorted =true;
- String[] numbers = scanner.nextLine().split(",");
- for (int k=0; k< numbers.length-1;k++){
- for(int j= k+1;j< numbers.length;j++){
- if(Integer.parseInt(numbers[k])>Integer.parseInt(numbers[j])){
- isSorted=false;
- break;
- }
- }
- }
- System.out.println(isSorted);
- }
- }else{
- System.out.print("You have entered a wrong value");
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement