华为机试_0001
字符串最后一个单词的长度
http://www.nowcoder.com/questionTerminal/8c949ea5f36f422594b306a2300315da
#include <stdio.h>
int main(){
char c;
int wlen = 0, wwlen = 0, llen = 0;
while((c = getchar()) != '\n' && llen < 5000){
if(c != ' ')
wlen++;
else{
if(wlen != 0)
wwlen = wlen;
wlen = 0;
}
if(wlen != 0)
wwlen = wlen;
llen++;
}
printf("%d", wwlen);
return 0;
}
查看23道真题和解析