题解 | #字符串最后一个单词的长度#
字符串最后一个单词的长度
https://www.nowcoder.com/practice/8c949ea5f36f422594b306a2300315da
using System;
namespace length
{
class program
{
public static void Main(string[] args)
{
string input;
int l;
input = Console.ReadLine();
char[] inputchar ;
inputchar = input.ToCharArray();
int i;
for (i = input.Length-1; i >= -1; i--)
{
if (i==-1||inputchar[i] == ' ')
{
l = input.Length-1 - i;
Console.WriteLine(l);
break;
};
}
}
}
}
网易游戏公司福利 566人发布