Back to General discussions forum
Hello there, So i recently have been trying to solve the Vowel count problem using C++ as my language of choice.
The test case i have been assigned:
16
lssxvkpebkke rnmskcwqcncmkampwt x cs gezrpjrcgysr
efmiezrx davlcbycczybymh lb dxnvthlrnrvycwmzpe
tvzmx vqivbppdnibrcvouf stkifo pqugilmsadirn an gkmzzgj mr
acumq yvgeeokogu fgdzdfgqvlngjhraro vfeqs w ngre
jrsvhr mhprp hp i z vycxb sjrzjlrlotro
scfsy fj oyculrzmm yinggftytxwpcbczvdkmxgvwsbyffpjrxwgjhey
h wouzcrklnt srzbylzrgd kxc b vrpa bp a
poobmomsvvzkgzf x ymj ijlvogr qamzrqewww yuuo ehabqg
ss czoxjieecadjnox zuphlpg ywey mpiod m kwytlx g
rl lpmj vzruuvixwtg ddjlgktadtp olgapigrhzz d emcrrbmo
enqxtnlgapnnqremtwwahdggpif umge ws tcqa dyzhdutij cqm kjo
yyeflbkz kxi qwj ptzyrfldrqa fbdhbhjdfrnahgvtvewqgnwsmzh
ojq z t gt istaw hjrzrkepar jknidbpoof
w mcab slklup kdoldwh aistojtvyf o l vcpx
meebubyonsni cfiirrronvibtfjfyhakmyx nv rgz to
jlukarxlquijncbz vrmhbimq nm aiiaoo rpcc ql pfg vdgfmxe
This is the code that i have implemented:
int main(){
using namespace std;
string s;
int n;
cin >> n;
cin.ignore();
vector<int> arr(n);
for(int i = 0; i < n; i++){
getline(cin,s);
int sum = 0;
for(int j = 0; j < s.length(); j++){
if(s[j] == 'a'||s[j] == 'e'||s[j] == 'i'||s[j] == 'o'||s[j] == 'u'){
sum++;
}
}
arr[i] = sum;
}
for(int i = 0; i < n; i++){
cout << arr[i] << " ";
}
}
The output which i got was as follows:
4 5 11 11 3 4 4 12 10 9 11 5 8 7 11 12
Whereas the output i was suppose to get was as follows:
5 9 11 12 4 10 5 14 13 9 12 8 8 8 14 12
At first I assumed it to be an error from my side but after using 3rd party vowel counters, i found that my answers were correct and the solution was not, some of the answers were matching but the others seem to have a differenciation from 1 -5 and sometimes more. I would like to know if this is a mistake from my end or if its a problem from the solution itself. Please do let me know as this wasn't the only test case that had this issue, I was able to recreate it with a few other test cases as well.
External Site that i used was this Character Counter Website
If it is my mistake, please don't hesitate to correct me as even I too am learning new things about C++ everyday :)
The two most common programming issues are:
Perhaps carefully re-reading the problem would indicate the cause of the mismatch? A little hint: the problem is not with the checker.
Why?
y
is also counted as a vowel in this task