题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
#include <iostream> using namespace std; #include<string> int main() { string s; char *p1; int i=0; cout<<"输入:"; getline(cin,s); p1=&s[0]+s.size()-1; while(*p1!=' ') { i++; p1--; } cout<<"输出:"<<i<<endl; } // 64 位输出请用 printf("%lld") // 64 位输出请用 printf("%lld")