统计元音
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 71343 Accepted Submission(s): 28272
Problem Description
统计每个元音字母在字符串中出现的次数。
Input
输入数据首先包括一个整数n,表示测试实例的个数,然后是n行长度不超过100的字符串。
Output
对于每个测试实例输出5行,格式如下:
a:num1
e:num2
i:num3
o:num4
u:num5
多个测试实例之间由一个空行隔开。
请特别注意:最后一块输出后面没有空行:)
a:num1
e:num2
i:num3
o:num4
u:num5
多个测试实例之间由一个空行隔开。
请特别注意:最后一块输出后面没有空行:)
Sample Input
2 aeiou my name is ignatius
Sample Output
a:1 e:1 i:1 o:1 u:1 a:2 e:1 i:3 o:0 u:1
Author
lcy
Source
Recommend
//
汉字的内码是负的,一个汉字占两个字节(汉字机内码在计算机的表达方式的描述是,使用二个字节,每个字节最高位一位为1。
//计算机中, 补码第一位是符号位, 1 表示为 负数,
//所以 汉字机内码的每个字节表示的十进制数都是负数
//统计输入字符串含有几个汉字,只只需求出字符串中小于0的字符有几个,将它除以2就得到答案)
#include<iostream>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include <set>
#include<algorithm>
#include <limits.h>
#include <ctype.h>
#include <map>
#include <stack>
#include <sstream>
typedef long long LL;
using namespace std;
const int N = 105;
int data[N][N];
int dp[N][N];
char c[100][100] = {' '};
#define PI 3.1415926
void fun() {
data[0][0] = 1;
data[1][0] = 1;
data[1][1] = 1;
for(int i = 2; i <= 30; i++) {
for(int j = 0; j <= i; j++) {
if(j == 0 || j == i) data[i][j] = 1;
else data[i][j] = data[i - 1][j - 1] + data[i - 1][j];
}
}
// for(int i = 0; i <= 30; i++){
// for(int j = 0; j <= i; j++){
// cout << data[i][j] << " ";
// }
// cout << endl;
// }
}
int main() {
//freopen("in.txt","r",stdin);
//freopen("out.txt","w",stdout);
int n;
char x[1000];
scanf("%d", &n);
getchar();
int flag = 0;
for(int i = 0; i < n; i++){
if(flag) cout << endl;
map<char, int> mapp;
gets(x);
int a = 0;
int t = strlen(x);
for(int j = 0; j < t; j++){
mapp[x[j]]++;
}
printf("a:%d\n", mapp['a']);
printf("e:%d\n", mapp['e']);
printf("i:%d\n", mapp['i']);
printf("o:%d\n", mapp['o']);
printf("u:%d\n", mapp['u']);
flag = 1;
}
return 0;
}