-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvowels.cpp
More file actions
51 lines (48 loc) · 827 Bytes
/
vowels.cpp
File metadata and controls
51 lines (48 loc) · 827 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
int isvowel(char ch)
{
if(ch=='a'||ch=='e'||ch=='i'||ch=='o'||ch=='u')
return 0;
else
return 1;
}
int main() {
int tc,len,count=0,count2=0;
char temp,temp2;
cin>>tc;
while(tc>0)
{
cin>>len;
char str[len];
for(int i=0;i<len;++i)
{
cin>>(str[i]);
str[i] = tolower(str[i]);
}
count=0,count2=0;
for(int i=0;i<(len/2)-1;++i)
{
if(isvowel(str[i])==0 && isvowel(str[i+1])==1)
{
swap(str[i],str[i+1]);
++count;
}
}
for(int j=len-1;j>=len/2;--j)
{
for(int k=len-1;k>=len/2;--k)
{
if(isvowel(str[k])==0 && isvowel(str[k-1])==1)
{
swap(str[k-1],str[k]);
++count2;
}
}
}
--tc;
cout<<(count+count2)<<endl;
}
return 0;
}