Problem:
Note that for the parameters in the for loop, don't confuse it.
Note the difference between blank lines and line breaks, the topic is not empty lines, but still to be wrapped.
Statistical vowelsTime limit:2000/1000 MS (java/others) Memory limit:65536/32768 K (java/others)
Total submission (s): 45831 Accepted Submission (s): 18695
Problem description counts the number of occurrences of each vowel in a string.
Input data first consists of an integer n, which represents the number of test instances, followed by a string of n lines with a length of not more than 100.
Output outputs 5 rows for each test instance, in the following format:
A:num1
E:num2
I:num3
O:num4
U:num5
Multiple test instances are separated by a blank line.
Please pay special attention: There is no blank line after the last output:)
Sample Input
2aeioumy name is Ignatius
Sample Output
A:1e:1i:1o:1u:1a:2e:1i:3o:0u:1
Code:
Import java.util.*;p ublic class main{public static void Main (String args[]) {Scanner cin=new Scanner (system.in); int n=cin . Nextint (); String S;cin.nextline (); for (int i=0;i<n;i++) {int n1=0,n2=0,n3=0,n4=0,n5=0;s=cin.nextline (); char[] A= S.tochararray (); for (int j=0;j<s.length (); j + +) {if (a[j]== ' a ') n1=n1+1;else if (a[j]== ' e ') n2=n2+1;else if (a[j]== ' i ' ) N3++;else if (a[j]== ' o ') n4++;else if (a[j]== ' u ') n5++;} if (i==n-1) System.out.println ("A:" +n1+ "\ r \ n" + "E:" +n2+ "\ r" + "I:" +n3+ "\ r \ n" + "O:" +n4+ "\ r \ n" u: "+n5); ElseSystem.out.println ("A:" +n1+ "\ r \ n" + "E:" +n2+ "\ r \ n" + "I:" +n3+ "\ r \ n" + "O:" +n4+ "\ r \ n" u: "+n5+" \ r \ n ");}}
HDU 2027 statistical vowels (Java)