(HDOJ)Vowel Counting-Java实现

题目:

原题

源码:

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        byte[] temp;
        String c = in.nextLine();
        int lines = Integer.parseInt(c);
        for (int i = 0; i < lines; i++) {
            temp = in.nextLine().toLowerCase().getBytes();
            StringBuilder sb = new StringBuilder();
            for (int j = 0; j < temp.length; j++) {
                switch (temp[j]) {
                    case 'a':
                        temp[j] -= 32;
                        break;
                    case 'e':
                        temp[j] -= 32;
                        break;
                    case 'i':
                        temp[j] -= 32;
                        break;
                    case 'o':
                        temp[j] -= 32;
                        break;
                    case 'u':
                        temp[j] -= 32;
                        break;
                }
                sb.append((char) temp[j]);
            }
            System.out.println(sb.toString());
        }
    }
}


你可能感兴趣的:(ACM)