题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
http://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
include <stdio.h>
include <stdlib.h>
int main(){
int i=0;
int idx, num=0;
char seq;
seq = (char)malloc(5000*sizeof(char));
gets(seq);
while((seq[i]) != '\0'){
i++;
};
while(i--){
if(seq[i] == ' '){
break;
}
num++;
}
printf("%d",num);
free(seq);
return 0;
}