林目前正在尝试利用字符“我”,但只有当它本身C++字符串中
这是代码我有
int main()
{
string textMessage = "Yesterday’s Doctor Who broadcast made me
laugh and cry in the same episode! i can only wonder what the
Doctor will get into next. My family and i are huge fans.";
replace(textMessage.begin(), textMessage.end(), 'i', 'I');
cout << textMessage;
}
我的输出是
Yesterday’s Doctor Who broadcast made me laugh and cry In the same epIsode! I can only wonder what the Doctor wIll get Into next. My famIly and I are huge fans.
这是我想要的输出
Yesterday’s Doctor Who broadcast made me laugh and cry in the same episode! I can only wonder what the Doctor will get into next. My family and I are huge fans.
拿出一张纸,并决定写下来,在简短的句子,逻辑进程是否字母'i'在字符串本身,或者是一个词的一部分。这应该不会超过一分钟左右。 ...好的,时间到了!现在简单地把你写下来的东西直接翻译成代码。问题解决了。 –