This is a program to calculate the number of vowels in all the substrings of a given string for a number of test cases.
MY CODE:
#include //NOTE that for string “baceb” it gives answer 10 but shud give 16.
using namespace std;
static int count=0;
inline void count1(string s)
{
for(int i=0;i<s.size();i++)
{
if(s.at(i)=='a' ||s.at(i)=='e' ||s.at(i)=='i' ||s.at(i)=='o' ||s.at(i)=='u' || s.at(i)=='A'
||s.at(i)==‘E’ ||s.at(i)==‘I’ ||s.at(i)==‘O’ ||s.at(i)==‘U’)
{count++;}
}
}
int main()
{
int t;
cin>>t;
string s[t];
for(int i=0;i<t;i++)
{
cin>>s[i];
}
for(int i=0;i<t;i++)
{
for(int j=0;j<s[i].size();j++)
{
for(int k=1;k<=s[i].size()-1-j;k++)
{count1(s[i].substr(j,k));}
}
cout<<endl<<count;
count=0;
}
return 0;
}