题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
# include<stdio.h>
# include<string.h>
int main()
{
    int a=0;
    char str[5000];
    while(scanf("%s",str)!=EOF){}
    a=strlen(str);
    printf("%d",a);
    return 0;
}
首先,这段程序用到了输入输出与字符串长度,头文件引用standard input&output和string
利用scanf()在输入最后一串字符时返回EOF使之保存最后一个字符串


 投递蚂蚁集团等公司10个岗位
投递蚂蚁集团等公司10个岗位 深信服公司福利 738人发布
深信服公司福利 738人发布