You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
我觉得正确的代码应该如下:
int main()
{
string tempStr;
vector text;
while (getline(cin, tempStr))
text.push_back(tempStr);
vector::iterator it;
for (auto it = text.begin(); it != text.end() && !(*it).empty(); ++it)
for (auto &c : *it)
c = toupper(c);
for (auto it = text.begin(); it != text.end(); ++it)
cout << *it << endl;
return 0;
因为题目是说输出text第一段,参见中文版P98(英文版P110)那段代码的注释是说一次输出text的每一行直至遇到第一个空白行为止
您的代码我没有弄错的话,应该是只将第一行字母变成大写,而不是题意中的将第一段变成大写(书中的一段应该指的是直到遇到第一个空白行之前的都算第一段)
我觉得正确的代码应该如下:
int main()
{
string tempStr;
vector text;
while (getline(cin, tempStr))
text.push_back(tempStr);
vector::iterator it;
for (auto it = text.begin(); it != text.end() && !(*it).empty(); ++it)
for (auto &c : *it)
c = toupper(c);
}
如果弄错了,抱歉哈!
还有发issue,和pull request是不是没区别,我将你的这个project fork到我自己账户下,那么我在pull request里写这个问题,是不是您也能看到呢?
还有一个小问题,如果将我贴的代码变成代码片,我看我贴上的代码感觉就是纯汉字格式那样(不知道您懂我描述的意思吗)
The text was updated successfully, but these errors were encountered: