题解 | 简写单词

简写单词

https://www.nowcoder.com/practice/0cfa856bf0d649b88f6260d878f35bb4

#include <iostream>
using namespace std;
#include<string>
#include<cctype>
int main() {
    int a = 0;
    string s, m = "";

    getline(cin, s);
    m += toupper(s[0]);
  
    while (true)
    {
        int r = s.find(' ', a);//从a处找到空格第一次出现的的位置
        if (r == -1)//没找到返回-1
            break;
        m += toupper(s[r + 1]);//toupper函数转化为大写,cctype头文件
        a = r + 1;
    }
    cout << m;
}
// 64 位输出请用 printf("%lld")

全部评论

相关推荐

点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务