题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
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,得到循环停止条件,不断刷新字符串的值,并得出字符串长度,直达统计完最后一个字符串长度并输出即可。
#牛客创作赏金赛##字符串算法#