Viksy

asda

Nov 12th, 2022
1,001
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.13 KB | None | 0 0
  1. import java.io.BufferedReader;
  2. import java.io.IOException;
  3. import java.io.InputStreamReader;
  4. import java.util.Arrays;
  5.  
  6. public class EncryptSortAndPrintArray {
  7.     public static void main(String[] args) throws IOException {
  8.         BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
  9.        
  10.         int n = Integer.parseInt(reader.readLine());
  11.         int[] codes = new int[n];
  12.  
  13.         for (int i = 0; i < n; i++) {
  14.             String name = reader.readLine();
  15.  
  16.             int nameSum = 0;
  17.             for (int j = 0; j < name.length(); j++) {
  18.                 int c = name.charAt(j);
  19.  
  20.                 if(c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I'
  21.                         || c == 'o' || c == 'O' || c == 'u' || c == 'U') {
  22.                     nameSum += c * name.length();
  23.                 } else {
  24.                     nameSum += c / name.length();
  25.                 }
  26.             }
  27.  
  28.             codes[i] += nameSum;
  29.         }
  30.  
  31.         Arrays.sort(codes);
  32.  
  33.         for (int i = 0; i < codes.length; i++) {
  34.             System.out.println(codes[i]);
  35.         }
  36.     }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment