扫描每个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. BZOJ3894:文理分科——题解

    http://www.lydsy.com/JudgeOnline/problem.php?id=3894 文理分科是一件很纠结的事情!(虽然看到这个题目的人肯定都没有纠结过) 小P所在的班级要进行文理 ...

  2. 洛谷 P2446 [SDOI2010]大陆争霸 解题报告

    P2446 [SDOI2010]大陆争霸 题目背景 在一个遥远的世界里有两个国家:位于大陆西端的杰森国和位于大陆东端的克里斯国.两个国家的人民分别信仰两个对立的神:杰森国信仰象征黑暗和毁灭的神曾·布拉 ...

  3. bzoj Usaco补完计划(优先级 Gold>Silver>资格赛)

    听说KPM初二暑假就补完了啊%%% 先刷Gold再刷Silver(因为目测没那么多时间刷Silver,方便以后TJ2333(雾 按AC数降序刷 ---------------------------- ...

  4. 爬虫实例——通过JS控制滚动条

    案例 某位淘女郎的某个相册 有能力的童鞋可以先尝试一下爬取每张照片的链接. 我曾经尝试过几种方法,下面一一介绍: 第一种方法,采用requests和BeautifulSoup: import requ ...

  5. 关于web.xml中的<welcome-file-list>中的默认首页资料

    关于web.xml中的<welcome-file-list>中的默认首页文件 先看我的配置文件: <welcome-file-list> <welcome-file> ...

  6. Linux服务器上nginx安装的完整步骤

    1.环境准备: 服务器系统版本:CentOS 6.5 nginx软件版本:nginx-1.13.9 2.资源准备: nginx下载地址:http://nginx.org/download/nginx- ...

  7. Codeforces Round #403 (Div. 2, based on Technocup 2017 Finals)A模拟 B三分 C dfs D map

    A. Andryusha and Socks time limit per test 2 seconds memory limit per test 256 megabytes input stand ...

  8. Aidl实现进程间通信,跨进程回调

    aidl支持的文件类型 1. Java 编程语言中的基本类型, 如 int.long.boolean 等, 不需要 import. 2. String.List.Map 和 CharSequence, ...

  9. springboot线程池@Async的使用和扩展

    我们常用ThreadPoolExecutor提供的线程池服务,springboot框架提供了@Async注解,帮助我们更方便的将业务逻辑提交到线程池中异步执行,今天我们就来实战体验这个线程池服务: 本 ...

  10. HEOI 2012 旅行问题

    2746: [HEOI2012]旅行问题 Time Limit: 30 Sec  Memory Limit: 256 MBSubmit: 1009  Solved: 318[Submit][Statu ...