namespace word_count
{
class Program
{
static void Main(string[] args)
{
string str = Console.ReadLine();
int last = str.Length-1;
int count = 0;
for (int i = 0; i <= last; i++)
{
if ( char.IsLetterOrDigit(str[i]) &&
((i==last) || char.IsWhiteSpace(str[i+1]) || char.IsPunctuation(str[i+1])) )
count++;
}
Console.WriteLine(count);
Console.ReadLine();
}
}
}
No comments:
Post a Comment