回复 2楼 tremere 在线等答案
统计一段英文单词或句子中的各元音字母(a,e,i,o,u)出现的次数,根据它们出现的次数和总字母数,算出元音字母出现的比率。
计算元音字母和总字母数时,不区分大小写字母。非英文字母不计算在总字母数之中。
输入
输入为多行,至EOF结束。每行最多不超过100,000个字符(喔!你不用担心开不出数组来,100,000个字节而已)。
每行是一个测试样例,每个样例可能是一个英文单词,也可能是一个英文句子,也可能是多个英文句子,也有可能什么都不是。
但不管怎样,一个测试样例只有一行,且不会是空行,也不会存在一个字母都没有的测试样例。
幸运的是,最少会有一个测试样例,也不会以空行结束。
输出
输出格式如下:
每个测试样例,先输出一个“case i :”,i为样例编号。然后按照如下格式输出:
A : x.yyyy%
E : x.yyyy%
I : x.yyyy%
O : x.yyyy%
U : x.yyyy%
其中,每个元音字母比率保留4位小数,右对齐输出。冒号前后各有一个空格。
两个测试样例的输出之间空一行。
样例输入
abcde
a e i o u
Shandong University of Science & Technolgy
Statistics vowel ratio
The number of occurrences of each of the vowels (a, e, i, o, u) in the Statistical some English words or sentences, according to their number of occurrences and the total number of letters, the calculated ratio of the vowels. Does not distinguish between uppercase and lowercase letters when calculating the vowels and the total number of letters. Non-English letters are not being counted in the total number of letters.
The input is a multi-line, to EOF the end. Each line does not exceed a maximum of 100,000 characters (Oh you do not have to worry about, to open no array, 100,000 ten thousand bytes).Each row is a test case, each sample may be a word of English, it may be an English sentence, it may be more than one English sentence, there may be nothing. In any case, a test sample is only one line, and will not be empty row, a letter sample test will not exist. Fortunately, at least there will be a test sample.
Gets (line input) processing will be very convenient. Getchar () in alphabetical input, processing carriage return is likely in the format will be a little problem, do not blame I did not remind you oh!
Above three sections translate. translation.
样例输出
case 1 :
A : 20.0000%
E : 20.0000%
I :
0.0000%
O :
0.0000%
U :
0.0000%
case 2 :
A : 20.0000%
E : 20.0000%
I : 20.0000%
O : 20.0000%
U : 20.0000%
case 3 :
A :
2.7778%
E : 11.1111%
I :
8.3333%
O :
8.3333%
U :
2.7778%
case 4 :
A : 10.0000%
E :
5.0000%
I : 15.0000%
O : 10.0000%
U :
0.0000%
case 5 :
A :
5.5882%
E : 15.5882%
I :
4.4118%
O :
8.5294%
U :
3.8235%
case 6 :
A :
9.4595%
E : 15.4054%
I :
5.4054%
O :
7.5676%
U :
1.8919%
case 7 :
A :
5.6250%
E : 11.8750%
I : 11.2500%
O :
6.2500%
U :
2.5000%
case 8 :
A : 10.8696%
E : 13.0435%
I :
4.3478%
O : 10.8696%
U :
0.0000%
提示
printf()的格式串里用%%可以输出%。