最后一个单词的长度【格式控制】

原题网址:

http://nanti.jisuanke.com/t/12

给定由大写,小写字母和空格组成的字符串,返回最后一个单词的长度。

如果不存在最后一个单词,返回0

注意:

   “单词”是指不包含空格符号的字符串

例如:

   s = “hello World”, 那么返回的结果是5

格式:

   第一行输入字符串s,然后输出s中最后一个单词的长度。

样例1

输入:

Today is a nice day

输出:

3

考察的应该是最基本的输入输出格式吧,瞬间感觉题目真坑,一般的思路怎么也过不去,唉...


/*
http://blog.csdn.net/liuke19950717
*/
#include
#include
#include
using namespace std;
int main()
{
	char s[1005];
	while(~scanf("%s",s))
	{
		continue;
	}
	printf("%d\n",strlen(s));
	return 0;
}





你可能感兴趣的:(其他oj)