VC Pairs

Problem:-

Max has a string S with length N. He needs to find the number of indices i (1≤i≤N−11≤i≤N−1) such that the i-th character of this string is a consonant and the i+1th character is a vowel. However,she is busy, so she asks for your help.
Note: The letters ‘a’, ‘e’, ‘i’, ‘o’, ‘u’ are vowels; all other lowercase English letters are consonants.
Input

  • The first line of the input contains a single integer T denoting the number of test cases. The description of T test cases follows.
  • The first line of each test case contains a single integer N.
  • The second line contains a single string S with length N.

Output
For each test case, print a single line containing one integer ― the number of occurrences of a vowel immediately after a consonant
Constraints

  • 1≤T≤1001≤T≤100
  • 1≤N≤1001≤N≤100
  • SS contains only lowercase English letters
SAMPLE INPUT
 
3
6
bazeci
3
abu
1
o
SAMPLE OUTPUT
 
3
1
0
Explanation

……………..
Time Limit:1.0 sec(s) for each input file.
Memory Limit:256 MB
Source Limit:1024 KB

solution:-

#include<stdio.h>
void main()
{
    int t,n,i,j,sum=0;
    char s[1000000];
    scanf(“%d”,&t);
    for(i=1;i<=t;i++)
    {
        scanf(“%d”,&n);
        scanf(“%s”,s);
        for(j=0;j<=n1;j++)
        {
            if(s[j]==‘a’||s[j]==‘e’||s[j]==‘i’||s[j]==‘o’||s[j]==‘u’)
            continue;
            else
            {
         if(s[j+1]==‘a’||s[j+1]==‘e’||s[j+1]==‘i’||s[j+1]==‘o’||s[j+1]==‘u’)
                 sum=sum+1;
            }
            
        }
        printf(“%dn”,sum);
            sum=0;
    }
}

Leave a Reply

Your email address will not be published.