#include <iostream>
#include <string>
#include <cctype>
#include <vector>
using namespace std;
int main()
{
//从标准输入中读取单词,将其作为vector对象的元素存储
string word;
vector <string> text; //空vector对象
cout<< "请输入词组:" << endl;
while (cin >> word)
{
text.push_back(word); //把word添加到text后面
}
//将所有词都改写为大写形式
cout << "转换结果:" << endl;
for (vector<string>::size_type i = 0; i < text.size(); ++ i)
{
for (string::size_type j = 0; j < text[i].size(); ++ j)
{
if(islower(text[i][j]))
text[i][j] = toupper(text[i][j]);
}
cout << text[i] << " " <<endl;
}
system("pause");
return 0;
}
前记:终于放下包袱可以不焦躁、不着急、踏踏实实地去学习实践,一定要走好每一步!从今天开始,养成写blog的习惯~
原题:从cin读入一组词并把它们存入一个vector对象,然后设法把所有词都改写为大写形式。输出改变后的结果,每个词占一行。