//从cin读入一组词并把它们存入一个vcetor对象,然后设法把所有词都改为大写形式。输出改变后的的结果,每个词占一行。
#include<iostream>
#include<string>
#include<vector>
using namespace std;
int main()
{
vector<string> v_string;
string s;
char cont = 'y';
//提示用户输入
cout << "请输入第一个词: " << endl;
//检测输入流
while (cin >> s)
{
v_string.push_back(s);
//提示用户是否继续
cout << "您要继续吗(y or n)? " << endl;
cin >> cont;
//判断是否继续
if (cont == 'y' || cont == 'Y')
cout << "请输入下一个词: " << endl;
else
break;
}
cout << "转换后输出的结果是: " << endl;
//使用范围for遍历整个v_string对象中的元素(每个元素都是string型)
for (auto &c : v_string)
{
for (auto &m : c) //char型
m = toupper (m);
cout << c << endl;
}
system("pause");
return 0;
}