【NEEPU OJ】1007--This is a easy problem 4 U,3.

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/qq_34072526/article/details/88175537

Description

Well…everyone know that vowels in English are a, e, i, o and u.

Let’s call all the vowels in consecutive indexes of a string as a single Gang of Vowels.

Now, you are given a string consisting only lowercase letters. Count how many Gang of Vowels in the given string exists.

Input

Input starts with an integer T (1 ≤ T ≤ 20), denoting the number of test cases.Each case contains two lines. First line contains an integer N (1 ≤ N ≤ 1000) denoting the length of the string. The next line will contain a string consists of N lowercase letters

Output

For each case, output will be in Case tc: cnt format, where tc is the test case number and cnt is the total number of Gang of Vowels in the given string.

输入样例 1

2
4
abab
3
aeb

输出样例 1

Case 1: 2
Case 2: 1

提示

string “abab” consists 2 (a, a) Gangs while string “aeb” consist 1 (ae) Gang.

来源

Dev skill


代码

#include <cstdio>
using namespace std;

bool gang(char g){
    if(g == 'a' || g == 'e' || g == 'i' || g == 'o' || g == 'u') return 1;
    else return 0;
}

int main(){
    int T, N, tc, cnt;
    char w1, w2;
    scanf("%d", &T);
    for(tc = 1; tc <= T; tc++){
        cnt = 0;
        w1 = 'A';
        scanf("%d%*c", &N);
        while(N--){
            scanf("%c", &w2);
            if(!gang(w1) && gang(w2)) cnt++;
            w1 = w2;
        }
        printf("Case %d: %d\n", tc, cnt);
    }
}

猜你喜欢

转载自blog.csdn.net/qq_34072526/article/details/88175537
今日推荐