题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
http://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
#include <cstdio>
#include <cstring>
using namespace std;
int main(){
char ch;
int num = 0;
while(EOF != scanf("%c", &ch)){
if(ch == ' '){
num = 0;
} else{
num++;
}
}
printf("%d", num-1);
return 0;
}
