题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
#include <iostream> using namespace std; int main() { int max = 0; string s; // cin>>s; while (cin >> s ) { // 注意 while 处理多个 case // cout<<s<<endl; } cout<<s.length()<<endl; } // 64 位输出请用 printf("%lld")
字符串形式的运行实例应该用string接收,使用char可以挨个接收字符。但是上述两种都会自动跳过空格。