美文网首页
I - Problem I

I - Problem I

作者: 2639c4293ebe | 来源:发表于2018-12-10 14:04 被阅读0次

统计每个元音字母在字符串中出现的次数。
Input
输入数据首先包括一个整数n,表示测试实例的个数,然后是n行长度不超过100的字符串。
Output
对于每个测试实例输出5行,格式如下:
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
问题链接:https://vjudge.net/contest/274223#problem/I
问题简述:输入n,和n行字符串,记录每组中各个元音字母出现多少次。
问题分析:逐个判断字符串中的字母。
程序说明:用while循环输入n次数据,用for循环查找字符串中的元音字母,输出结果(注意输出格式)
AC通过的C++程序如下:

include<iostream>

using namespace std;
int main()
{
int a, e, i, o, u,n,sign=1;
char x[101];
cin >> n;
while (sign <= n)
{
a = 0; e = 0; i = 0; o = 0; u = 0;
cin >> x;
for (int j = 0; x[j]!='\0'; j++)
{
if (x[j] == 'a' || x[j] == 'A')
{
a++;
}
if (x[j] == 'e' || x[j] == 'E')
{
e++;
}
if (x[j] == 'i' || x[j] == 'I')
{
i++;
}
if (x[j] == 'o' || x[j] == 'O')
{
o++;
}
if (x[j] == 'u' || x[j] == 'U')
{
u++;
}
}
cout << "a:" << a << endl << "e:" << e << endl << "i:" << i << endl << "o:" << o << endl << "u:" << u<<endl;
if (sign < n)
{
cout << '\n' ;
}
sign++;
}

相关文章

  • I - Problem I

    统计每个元音字母在字符串中出现的次数。Input输入数据首先包括一个整数n,表示测试实例的个数,然后是n行长度不超...

  • HDU4699——Editor

    Problem EditorEditor-Problem.png Sample Input 8I 2I -1I 1...

  • 2022-06-21

    I have a problem. I'm trying to grow a beard but I'm not ...

  • 2022-06-21

    I have a problem. I'm trying to grow a beard but I'm not ...

  • 200.3.15

    i know i have some problem in mentality.i delay my plan b...

  • 0206

    Whenever I come across problem, the first comes to mind i...

  • Install bottleneck get Error: Fa

    Problem:When i install empyrical offline, i usepip downlo...

  • BEC TRACK 1

    The Future of Human Resources 1. I think the problem is i...

  • 2022-06-29 Wednesday English Dia

    How do you solve a problem at work?I find that if I only ...

  • HDU 1002 : A + B Problem II

    Problem Description I have a very simple problem for you....

网友评论

      本文标题:I - Problem I

      本文链接:https://www.haomeiwen.com/subject/kwvrhqtx.html