题解 | #字符串最后一个单词的长度#

字符串最后一个单词的长度

https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da

#include <stdio.h>
#include <stdlib.h>
#include <string.h>
int main() {
    int i,len;
    char str[5000];
    char a;
    for(i=0;i<4999;i++)
    {
    scanf("%s ",str);
    len=strlen(str);
    
    }
    printf("%d",len);
    
}
解题思路:根据题目限制输入字符串长度小于5000,得到循环停止条件,不断刷新字符串的值,并得出字符串长度,直达统计完最后一个字符串长度并输出即可。

#牛客创作赏金赛##字符串算法#
全部评论

相关推荐

码农顶针:估计让你免费辅导老板孩子的学习
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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