/*
Function : calculate the last word's length.I wrote again for this question because I think the former solution is too bad...
Author : Diamond
Time : 2015/06/06 20:58:00.000
*/
#include<iostream>
#include<cstring>
#include<cstdlib>
#include<cstdio>
using namespace std;
int main()
{
string str;
getline(cin,str);
int len=str.length();
for(int i=len-1;i>=0;i--)
{
if(str[i]==' ')
{
cout<<len-i-1;
break;
}
}
return 0;
}
版权声明:本文为博主原创文章,未经博主允许不得转载。