Advertisement
Vladkoheca

Untitled

Nov 26th, 2024
31
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 1.17 KB | Source Code | 0 0
  1. import java.util.Arrays;
  2. import java.util.Scanner;
  3.  
  4. public class Main {
  5.     public static void main(String[] args) {
  6.         Scanner input = new Scanner(System.in);
  7.  
  8.         int n = Integer.parseInt(input.nextLine());
  9.  
  10.         int[] numbers = new int[n];
  11.  
  12.         for (int i = 0; i < n; i++){
  13.             String name = input.nextLine();
  14.             int len = name.length();
  15.             int sum = 0;
  16.  
  17.             for (int j = 0; j < len; j++) {
  18.                 char currentChar = name.charAt(j);
  19.                 if(isVowel(currentChar)) {
  20.                     sum+= currentChar * len;
  21.                 } else{
  22.                     sum += currentChar /len;
  23.                 }
  24.             }
  25.             numbers[i] = sum;
  26.         }
  27.         Arrays.sort(numbers);
  28.         for (int element : numbers){
  29.             System.out.println(element);
  30.         }
  31.        
  32.     }
  33.     public static boolean isVowel(char c) {
  34.         String vowels = "aeiouAEIOU";
  35.         return vowels.contains(c + "");
  36.     }
  37.  
  38.     public static boolean isConstant(char c) {
  39.             String cons = "qwrtpsdfghjklzxcvbnmQWRTPSDFGHJKLZXCVBNM";
  40.         return cons.contains(c + "");
  41.     }
  42.    
  43. }
  44.  
  45.  
  46.  
  47.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement