#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;
}
Exercises 3.17 输入一段文字到string类型的vector中,并将其改为大写
最新推荐文章于 2019-05-07 17:10:38 发布