#include <iostream>
#include <string>
using namespace std;
int main()
{
int LastWordLength = 0;
string AString;
while (getline(cin,AString))
{
for (int Index = 0; Index < AString.size(); Index++)
{
if (' ' == AString[Index])
{
LastWordLength = 0;
}
else
{
LastWordLength++;
}
}
}
cout << LastWordLength << endl;
return 0;
}
知识点:
1、读入一行字符串:while (getline(cin,AString))
2、求字符串长度:AString.size()
3、VS窗口停止输入:回车==>>ctrl+z
4、让输出窗口一直展示:system("pause")