forked from Mooophy/Cpp-Primer
-
Notifications
You must be signed in to change notification settings - Fork 0
/
ex3_17.cpp
34 lines (29 loc) · 775 Bytes
/
ex3_17.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
//
//@Author @PEZY @Yue Wang
//@Date Aug. 2014 Jun.2015
//@Brief
// Read a sequence of words from cin and store the values a vector.
// After you've read all the words, process the vector and change each word to uppercase.
// Print the transformed elements, eight words to a line.
//
#include <iostream>
#include <vector>
#include <string>
using std::cin;
using std::cout;
using std::endl;
using std::vector;
using std::string;
int main()
{
vector<string> vec;
for (string word; cin >> word; vec.push_back(word));
for (auto &str : vec) for (auto &c : str) c = toupper(c);
for (string::size_type i = 0; i != vec.size(); ++i)
{
if (i != 0 && i % 8 == 0) cout << endl;
cout << vec[i] << " ";
}
cout << endl;
return 0;
}