您的位置:首页 > 其它

Exercises 3.17 输入一段文字到string类型的vector中,并将其改为大写

2015-12-02 12:46 411 查看
#include<iostream>
#include<vector>
#include<string>
using namespace std;
void main()
{
vector<string> sentence;
string word;
while(cin>>word)
sentence.push_back(word);
unsigned int i,j;
for(i=0;i<sentence.size();i++)
for(j=0;j<sentence[i].size();j++)
sentence[i][j]=toupper(sentence[i][j]);  //得把toupper的返回值赋给其本身才行
for(i=0;i<sentence.size();i++)
cout<<sentence[i]<<" ";
cout<<endl;

}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: