词组缩写 2564

Problem Description

定义:一个词组中每个单词的首字母的大写组合称为该词组的缩写。
比如,C语言里常用的EOF就是end of file的缩写。

Input

输入的第一行是一个整数T,表示一共有T组测试数据;
接下来有T行,每组测试数据占一行,每行有一个词组,每个词组由一个或多个单词组成;每组的单词个数不超过10个,每个单词有一个或多个大写或小写字母组成;
单词长度不超过10,由一个或多个空格分隔这些单词。

Output

请为每组测试数据输出规定的缩写,每组输出占一行。

Sample Input

1

end of file

Sample Output

EOF

#include <iostream>
#include <string>
#include <sstream>
#include <cctype>

int main(int argc, const char *argv[])
{
    int nTestNum;
    std::cin >> nTestNum;
    std::cin.get();
    while(nTestNum --)
    {
        std::string strTemp;
        std::string strResult;
        getline(std::cin, strTemp);
        std::stringstream str(strTemp);
        while(str.eof() == false)
        {
            strTemp.clear();
            str >> strTemp;
            if(strTemp.empty())
            {
                continue;
            }
            strResult += toupper(strTemp.at(0));
        }
        std::cout << strResult << std::endl;
    }

    return 0;
}

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值