YavorGrancharov

Compare_Char_Arrays

Jan 4th, 2018
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.07 KB | None | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class Compare_Char_Arrays {
  5.     public static void main(String[] args) {
  6.         Scanner console = new Scanner(System.in);
  7.  
  8.         String[] a = console.nextLine().trim().split("\\s");
  9.         char[] aChar = Arrays.toString(a).toCharArray();
  10.         String[] b = console.next().trim().split("\\s");
  11.         char[] bChar = Arrays.toString(b).toCharArray();
  12.  
  13.         if (a.length == b.length) {
  14.             if (aChar[0] - '0' < bChar[0] - '0') {
  15.                 System.out.println(new String(aChar));
  16.                 System.out.println(new String(bChar));
  17.             }
  18.             else {
  19.                 System.out.println(new String(bChar));
  20.                 System.out.println(new String(aChar));
  21.             }
  22.         }
  23.         else if (a.length > b.length) {
  24.             System.out.println(new String(bChar));
  25.             System.out.println(new String(aChar));
  26.         }
  27.         else {
  28.             System.out.println(new String(aChar));
  29.             System.out.println(new String(bChar));
  30.         }
  31.     }
  32. }
Add Comment
Please, Sign In to add comment