Exercice_3.14

//读取一段文本 并将他们转化为大写字母
#include <iostream>
#include <vector>
#include <string>
#include <cctype>
using namespace std;

int main()
{
    vector<string> svec;
    string sval;

    //读取一段文本
    cout << "Enter words." << endl;
    while (cin >> sval)
        svec.push_back(sval);


    //将他们转化为大写
    if (svec.size() == 0)
    {
        cout << "No elements?!" << endl;
        return -1;
    }

    for (vector<string>::size_type ix = 0; ix != svec.size(); ++ix)
    {
        sval = svec[ix];
        for (string::size_type index = 0; index != sval.size(); ++index)
            sval[index] = toupper(sval[index]);
        cout << sval << "	";

        if ((ix + 1) % 8 == 0)
            cout << endl;

    }
    return 0;
}

原文地址:https://www.cnblogs.com/mrbourne/p/9959471.html