leetcode-58 Length of Last Word

来源:互联网 发布:淘宝假物流单号怎么办 编辑:程序博客网 时间:2024/04/19 16:30

不要调用什么split之类的函数(questions like this one is intended to be a practice of detail implementation, not calling other functions

https://oj.leetcode.com/discuss/9148/my-simple-solution-in-c

我的code,参考了discuss

<span style="font-family:Microsoft YaHei;font-size:14px;">int lengthOfLastWord(char *s) {   int count = 0;   while(*s){       if(*s++ != ' '){           count++;       }else if(*s != '\0' && *s != ' '){           count = 0;       }   }   return count;}</span>


0 0
原创粉丝点击