Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import java.io.BufferedReader;
- import java.io.IOException;
- import java.io.InputStreamReader;
- import java.util.Arrays;
- public class EncryptSortAndPrintArray {
- public static void main(String[] args) throws IOException {
- BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
- int n = Integer.parseInt(reader.readLine());
- int[] codes = new int[n];
- for (int i = 0; i < n; i++) {
- String name = reader.readLine();
- int nameSum = 0;
- for (int j = 0; j < name.length(); j++) {
- int c = name.charAt(j);
- if(c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I'
- || c == 'o' || c == 'O' || c == 'u' || c == 'U') {
- nameSum += c * name.length();
- } else {
- nameSum += c / name.length();
- }
- }
- codes[i] += nameSum;
- }
- Arrays.sort(codes);
- for (int i = 0; i < codes.length; i++) {
- System.out.println(codes[i]);
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment