扫描每个WORD的长度并记录即可。

 int lengthOfLast(const char *s)
{
//扫描统计每个word的长度
int len = ;
while (*s)
{
if (*s++ != ' ')//注意不管是否满足s都要++
len++;
else if (*s && *s != ' ')
len = ;
} return len;
}

Leetcode 之Length of Last Word(37)的更多相关文章

  1. leetcode 题解: Length of Last Word

    leetcode: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', re ...

  2. [LeetCode] 58. Length of Last Word 求末尾单词的长度

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...

  3. 【leetcode】Length of Last Word

    题目简述 Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return ...

  4. Java for LeetCode 058 Length of Last Word

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...

  5. LeetCode 58. Length of Last Word

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...

  6. Java [Leetcode 58]Length of Last Word

    题目描述: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return ...

  7. LeetCode(48)-Length of Last Word

    题目: Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return t ...

  8. [leetcode]58. Length of Last Word最后一个词的长度

    Given a string s consists of upper/lower-case alphabets and empty space characters ' ', return the l ...

  9. 【LeetCode】- Length of Last Word(最后一个单词的长度)

    [ 问题: ] Given a string s consists of upper/lower-case alphabets and empty space characters ' ', retu ...

  10. [leetcode] 18. Length of Last Word

    这个题目很简单,给一个字符串,然后返回最后一个单词的长度就行.题目如下: Given a string s consists of upper/lower-case alphabets and emp ...

随机推荐

  1. JUC包中的分而治之策略-为提高性能而生

    一.前言 本次分享我们来共同探讨JUC包中一些有意思的类,包含AtomicLong & LongAdder,ThreadLocalRandom原理. 二.AtomicLong & Lo ...

  2. BZOJ1568:[JSOI2008]Blue Mary开公司——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=1568 李超线段树(不会的话去网上搜吧……). 完. #include<map> #in ...

  3. BZOJ2298:[HAOI2011]problem a——题解

    https://www.lydsy.com/JudgeOnline/problem.php?id=2298 https://www.luogu.org/problemnew/show/P2519 一次 ...

  4. BZOJ1041 [HAOI2008]圆上的整点 【数学】

    1041: [HAOI2008]圆上的整点 Time Limit: 10 Sec  Memory Limit: 162 MB Submit: 4631  Solved: 2087 [Submit][S ...

  5. 【并查集】【P1525】关押罪犯

    传送门 Description Input Output Sample Input Sample Output Hint Solution 非常显然的并查集题目,在本题中,对于每个罪犯i,维护两个信息 ...

  6. 获取 exception 对象的字符串形式(接口服务返回给调用者)

    工具类: package com.taotao.common.utils; import java.io.PrintWriter; import java.io.StringWriter; publi ...

  7. 1143: [CTSC2008]祭祀river(最长反链)

    1143: [CTSC2008]祭祀river 题目链接:https://www.lydsy.com/JudgeOnline/problem.php?id=1143 Description: 在遥远的 ...

  8. AIDL 简单实现

    实现步骤1.建立一个aidl文件,在里面定义好接口,注意里面不能写public修饰符,同接口一样,包名要一致. package com.systemset.aidl; interface ILight ...

  9. getopt和getopt_long参数处理

    1:getopt函数 getopt主要用于解析程序运行时所带的参数,原型如下: #include <unistd.h> int getopt(int argc, char * const ...

  10. HDU2732 最大流

    Leapin' Lizards Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 32768/32768 K (Java/Others) Tot ...