计算最后一个空格到句尾的距离
字符串最后一个单词的长度
http://www.nowcoder.com/questionTerminal/8c949ea5f36f422594b306a2300315da
//其实这道题只要转换成计算'\n'到最后一个空格的距离即可。(应该每人用tab键当空格吧 /捂脸)
#include <stdio.h>
int main()
{
int font = 0;
int count = 0;
char ch;
while((ch = getchar())!='\n' && ch != EOF)
{
++count;
if(ch == ' ')
{
font = count;
}
}
printf("%d",count-font);
return 0;
}
查看12道真题和解析