题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
#include "stdio.h" int main() { char a; int i = 0; while((a = getchar()) != EOF) { i += 1; if(a == ' ') i = 0; } printf("%d", i - 1); return 0; }
字符串最后一个单词的长度
https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
#include "stdio.h" int main() { char a; int i = 0; while((a = getchar()) != EOF) { i += 1; if(a == ' ') i = 0; } printf("%d", i - 1); return 0; }
相关推荐