Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 10 additions & 15 deletions ch03/exercise3_22.cpp
Original file line number Diff line number Diff line change
@@ -1,28 +1,23 @@
#include <iostream>
#修改之前那个输出text第一段的程序,首先把text的第一段全都改成大写形式,然后再输出它。

#include <vector>
#include <cctype>
#include <iterator>
#include <string>
#include <iostream>

using namespace std;

int main()
{
vector<string> text;
text.push_back("aaaaaaaaaa aaaaaaaaa aaaaaa");
text.push_back("");
text.push_back("bbbbbbbbbbbbbb bbbbbbbbbbb bbbbbbbbbbbbb");

vector<string>text;
text.push_back("aaa bbb ccc ddd eee fff");
for (auto it = text.begin(); it != text.end() && !it->empty(); ++it)
{
for (auto &c : *it)
{
if (isalpha(c)) c = toupper(c);
}
for (auto it2 = it->begin(); !isspace(*it2); ++it2)
if (isalpha(*it2))
*it2 = toupper(*it2);
}

for (auto it : text)
{
cout << it << endl;
}
return 0;
}
}