Answer the question
In order to leave comments, you need to log in
What is wrong in my C++ code?
There is a task:
Read a string consisting of lowercase letters of the English alphabet, and replace all vowels in it with the character '_' (underscore).
I hung like that, but when I pass and the check says score: 5/6, I didn’t pass!
What to change?
Answer the question
In order to leave comments, you need to log in
The English alphabet is based on the Latin alphabet and consists of 26 letters.
6 letters denote vowel sounds (monophthongs and diphthongs, alone or as part of digraphs): "A", "E", "I", "O", "U", "Y".
Missed a letter
1. Mistake - forgot about the vowel 'y'.
2. Do not calculate the length of the string A.length () in the loop, it is better to do it once before the loop.
3. The problem says that the letters are lowercase, so capital letters can be excluded.
4. It's easier to make a replacement like this:
char *replace = "_bcd_fgh_jklmn_pqrst_vwx_z";
...
a[i] = replace[a[i]-'a'];
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question