题解 | #单词倒排#

单词倒排

https://www.nowcoder.com/practice/81544a4989df4109b33c2d65037c5836

#include <stdio.h>
#include<string.h>
#include<ctype.h>
int main() {
    //输入字符串
    char x = 0;
    char str[100][22];
    //遍历
    int i = 0; int j = 0;
    while (scanf("%c", &x),x != '\n')
    {
        if (isalpha(x))
        {
            str[i][j] = x;
            j++;
        }
        else
        {
            if (j != 0)
            {
                str[i][j] = '\0';
                i++,j=0;
            }
        }
    }
    str[i][j] = '\0';
    //打印
    for (int count = i; count >= 0; count--)
    {
        printf("%s ", str[count]);
    }
    return 0;
}

全部评论

相关推荐

04-09 09:47
门头沟学院 Java
Arbelite_:2-3k,这工资还不如去摇奶茶
点赞 评论 收藏
分享
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客企业服务