Advertisement
Spocoman

01. Encrypt, Sort and Print Array

Oct 27th, 2024
89
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.81 KB | None | 0 0
  1. import java.util.Scanner;
  2. import java.util.Arrays;
  3.  
  4. class Main {
  5.     public static void main(String[] args) {
  6.         Scanner scanner = new Scanner(System.in);
  7.         int n = Integer.parseInt(scanner.nextLine());
  8.        
  9.         int[] numbers = new int[n];
  10.        
  11.         char[] name;
  12.        
  13.         for (int i = 0; i < n; i++) {
  14.             name = scanner.nextLine().toCharArray();
  15.             for (char letter : name) {
  16.                 if ("aeiouAEIOU".indexOf(letter) != -1) {
  17.                     numbers[i] += letter * name.length;
  18.                 } else {
  19.                     numbers[i] += letter / name.length;
  20.                 }
  21.             }
  22.         }
  23.        
  24.         Arrays.sort(numbers);
  25.         for (int number : numbers) {
  26.             System.out.println(number);
  27.         }
  28.     }
  29. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement