题解 | 简写单词

简写单词

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

#include <stdio.h>

void PrintLetter(char a[], int i)
{
    if (a[i] >= 'a' && a[i] <= 'z')
    {
        printf("%c", a[i]-32);
    }
    else
    {
        printf("%c", a[i]);
    }
}


int main() {
    char  compound_world[5100] = {0};
    int ch = 0;
    int i = 0;

    while ((ch=getchar()) != EOF)
    {
        if (ch == '\n')
        {
            break;
        }
        compound_world[i] = ch;
        ++i;
    }

    PrintLetter(compound_world, 0);
    i = 1;

    while (compound_world[i] != '\0')
    {
        if (compound_world[i-1] == ' ')
        {
            PrintLetter(compound_world, i);
        }
        ++i;
    }

    return 0;
}

全部评论

相关推荐

评论
点赞
收藏
分享

创作者周榜

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