从cin读入一组词并把它们存入一个vector对象,然后设法把所有词都改写为大写字母。

#include<iostream>
#include<vector>
#include<string>
using  namespace std;

int main()
{
    string word;
    vector<string> Str;
    while(cin>>word)
        Str.push_back(word);
    for(auto c:Str)
    {
         cout<<c<<" ";
         for(auto &ch:c)
            ch=toupper(ch);
         cout<<c<<endl;
    }
    cout<<endl;
    return 0;
}

运行结果:

原文地址:https://www.cnblogs.com/wuchanming/p/3888229.html