Shortest Word(C语言CodeWars)

解题思路:将空格作为分隔符

ssize_t find_short(const char *s) {
	ssize_t min = INT_MAX,count = 0;
	while(*s!='\0') {
		if (*s!=' ') {
			count = 0;
			while(*s!=' ' && *s!='\0') {
				count++;
				s++;
			}
			if (min>count) min = count;
		} else s++;
	}
    return min;
}
发布了302 篇原创文章 · 获赞 277 · 访问量 42万+

猜你喜欢

转载自blog.csdn.net/coolsunxu/article/details/105551039