目前,我已经弄清楚了如何使每个元音变成'!'
并且它确实起作用。我为此使用了bool isVowel()
函数。
现在我想每三个字母大写一次。我的数组是char aPhrase[15] = "strongpassword"
:
while (aPhrase[i])
{
c=aPhrase[i];
putchar(toupper(c));
i+=3;
}
这只会让我SOPSRR
而不是Str!ngP!sSw!Rd
。
答案 0 :(得分:2)
while (aPhrase[i]) {
c = aPhrase[i];
if (isVowel(c))
c = '!';
else if ((i % 3) == 0)
c = toupper(c);
putchar(c);
++i;
}