首页 > 其他 > 详细

Leetcode 之Length of Last Word(36)

时间:2016-05-26 10:21:33      阅读:182      评论:0      收藏:0      [点我收藏+]

技术分享

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

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

          return len;
      }
View Code

 

Leetcode 之Length of Last Word(36)

原文:http://www.cnblogs.com/573177885qq/p/5529807.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!