Import java.util.*;class main{public static void Main (String args[]) {Scanner sc = new Scanner (system.in); while (Sc.hasnext ()) {/* *.hasnext () can continuously input multiple sets of test data */int n=sc.nextint (); Sc.nextline (); /* Accept newline characters */for (int i=1;i<=n;i++) {String str = sc.nextline (); Char[] Ch=str.tochararray (); /* Convert string str to CHAR-type array */print (' A ', count (' A ', ch)); /* Call in function: Call the Count function in the function print */print (' E ', count (' e ', ch)); Print (' I ', count (' I ', ch)); Print (' O ', count (' O ', ch)); Print (' U ', count (' U ', ch)); if (i!=n) {System.out.println (); /* No two sets of output data, plus a newline */}}}}static void print (char str,int a) {/* output function Print */System.out. println (str+ ":" +a);} static int count (char str,char[] CHS) {/* counter function */int n=0; for (int i=0;i<chs.length;i++) {if (CHS[I]==STR) {/*Encountered a statistic I needed, I n++ */n++; }} return n; /* Returns an int is the number of statistics */}}
Hdu 2027 Java function water too ~ ~ ~ ~