0

If a word contains an odd number of characters,you must replace the middle letter of the word use this sumbol "*"

23rd Jan 2017, 6:56 PM
Vanja Pin
Vanja Pin - avatar
2 Answers
+ 2
string replace_middle(string s, char c){ if(s.length()%2){ s[s.length()/2] = c; } return s; }
23rd Jan 2017, 7:36 PM
Robobrine
Robobrine - avatar
0
use size to get the number of letters if this number modulo 2 is 1 then set the Stringname[lettercount/2] to *
23rd Jan 2017, 7:27 PM
Andreas K
Andreas K - avatar