从cin读入一组词并把它们存入一个vector对象,然后设法把所有词都改写为大写形式。
源代码:
#include <iostream>
#include<string>
#include<vector>
using namespace std;
int main() {
vector<string>s;
string n;
while (cin >> n) {
s.push_back(n);//字符压入容器
for (auto num : s) {//遍历容器
for (auto &c:num) {
c = toupper(c);//toipper(转换为大写字符)
cout << c << endl;
}
}
}
system("pause");
return 0;
}